answersLogoWhite

0

What is class and method in java?

Updated: 8/10/2023
User Avatar

Wiki User

12y ago

Best Answer

Class in Java is a blueprint which is used to create objects in Java. Class contains both methods and variables and that's how it is different with C struct construct. in Java there are built in classes like System Classes and you can also create class by using keyword "class" which we call user defined classes or application classes.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

I don't understand what you mean..if you mean a file with extension .class, so this is answer : Class is a file which created after you compile a java file without any error. For example, if your java file is Test.java, after compilation without any error, you will get Test.class.

If you mean keyword 'class', this is answer : It consists of a group of related methods and variables lumped together under one name. Like we know java is base on OOP(Object Oriented Programming). For example car is an example of object. So in java car like a class with method like break() and acceleration().

I hope it will help.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

A class has only two possible types of members: data members (variables) and member functions.

In the Java lexicography, class variables are called its Attributes, and all class functions are called Methods.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Class is an executable java file. for eg:HelloWorld.java, When you compile it you will get HelloWorld.class file whic user cannot read or edit.

Methods are individual blocks used inside your .java file for performing different operations you required.

Ex:AddSum()

{

int a,b,c;

a=b+c;

sysout(a);

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

whatever we write inside a class i.e variable or function is called member of a class.if the member is a variable it is called member variable and if it is a function then it is called a member function.

.................Rajesh kumar Mahato

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Static keyword when used with a method, specifies that this method belongs to the class and not a particular instance of the class (a.k.a object of the class)

Ex:

public class StaticTest {

public static String getAuthorName() {

return "Anand";

}

}

Here getAuthorName is the static method and it can be accessed without instantiating an object of the class StaticTest. You can access this method as:

String authorName = StaticTest.getAuthorName();

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Oddly enough, there is a Java class named Class. It provides an easy way to tell if two unknown Objects are of the same type (through use of the Object.class method).

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

a class is a def.of a highlevel data type.a class will tell what type of data and what methods of all instances of that class will have

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

A Class is a group of similar objects.Class is a blueprint of an object. Each object belongs to some class.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is class and method in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What will happen if a Java Class has no Main Method?

Nothing will happen. There is no restriction that every Java class must have a main method. The only program is that, this class cannot be executed as a standalone java program.


How do you call main class with in main class in java?

We can't call a class. We always call a method in java.


What is static java most commonly used for?

Static java method is the same as a static variable. They belong to a class and not an object of that class. If a method needs to be in a class, but not tied to an object, then one uses static java.


When do you declare a method or class abstract in java?

when overriding of a class or a method is necessary, they can be declared as abstract


What is function in java terminology?

In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.


Are you allowed to declared main method in every class?

Yes. Every Java class can have a main method


What is a driver class in Java?

The driver class is often the class that contains the "Main" method.


How nesting of methods is done in java?

No, Java only allows a method to be defined within a class, not within another method.


What is parent class in java?

Object Class is the parent class of all classes in java.Every class in the Java system is a descendant (direct or indirect) of the Object class.


How do you campaire Strings in java?

String class in Java has an 'equals' method that can be used to compare strings.


What is method call in java?

Calling a method in Java is when you run code associated with a specific class, using the name of an instance object of a class, followed by the dot operator, followed by the name of the method, followed by the arguments of the method, enclosed in parentheses.


What is inline declaration?

It is a declaration of java class in method body which called "inner class"