Gadgets

Sunday, 17 February 2013

Class and Object in Java


Class: -
A class is group of name that represents properties and actions of objects.
Class doesn’t exist physically. Every java program must contain at least one class. Class name should stars with Capital.
Example:-
public class Student {
                                            Class name
}   
group of objects is called class                              
Object: -
An Object is anything exists really in the world. An Object contains properties and performs actions.
Example:-
ClassName ojectname=new ClassName();
Student stu=new Student();
New is a Keyword Which is used when we are Creating an object of class For Storing all the data like variables and member functions  of class  there is some memory Space that is to be needed So that With the help of new Keyword and Object is Instantiated or Simply an object Reserves  

We can use object two different ways
1.      Student st=new Student();
It store the values and allocate the memory



2.     Student st;
        St=new Student();
its allocates memory first and then store values


public static void main(String args[]): -
JVM starts execution of a java program from the main method.
Public keyword is an access specifier.
Static is a method that can be called main method without using any object.
Void does not return any value.
Main() is method where java application begins.
Java stores anything in string format.
args[] is a variable. [] is called array format, its stores anything in array format.
[] is group of elements.

No comments:

Post a Comment