Login    New User    Forgot Password    Help      

Classes and Objects

Java Tutorials

A class is nothing but a blueprint or a template for creating different objects which defines its properties and behaviors. Java class objects exhibit the properties and behaviors defined by its class. A class can contain fields and methods to describe the behavior of an object.

Methods are nothing but members of a class that provide a service for an object or perform some business logic. Java fields and member functions names are case sensitive. Current states of a class’s corresponding object are stored in the object’s instance variables. Methods define the operations that can be performed in java


class abc
int a;
int b;
class clas1
public static void main(String args[])
// Create ob1 object of class abc
abc ob1=new abc();


System.out.println("Value of a is "+ ob1.a);
System.out.println("Value of b is "+ob1.b);


e:\java clas1

Value of a is 10

Value of b is 20

Java Tutorials