Computer Notes, Programming codes, Hardware and Networking Tip, Entertainment, Biography, Internet Tip, Tech News, Latest Technology, YouTube,

Define the term class and object? How can you create class and object in Java? Explain with example.

Java, Java program to create class and object, java class and object example, what is class?, what is object?, define object and class, Define the term class and object? , How can you create class and object in Java? Explain with example.

Class is a blueprint to template of real world objects that specifies what data and what methods will be included in object of the class. Class is also called description group of object objects having similar properties. A class is also called user defined data type or programmers defined data type because we can define new data types according to our need by using classes.

Objects are instances of class. We can say that object is variable of class type. Memory for instance declaration rather at the time of class declaration rather than time of object creation. Thus we can say that objects have physical existence and classes are only concepts.


Declaring Classes
Syntax:
       [Access Modifier] className{
                 // body
       }

Creating Object
Syntax:
       [className] [objectName] = new [className]();

Program
 
class Demo{
 void display(){
  System.out.println("Class Example");
 }
 public static void main(String args[]){
  Demo obj = new Demo(); 
  obj.display(); 
 }
}


Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget