Monday, 16 September 2019

Simple Program for creating object in JAVA.

                        Java Program for Object Creation



1. Open notepad file.
2. Write the code given below in notepad.

class Student
{
String name;
String age;
public static void main(String arg[])
{//Creating Object of Student class
Student  obj= new Student(); // calling default constructor while creating object
System.out.println("Default Name of Object "+obj.name);
System.out.println("Default Age of Object "+obj.age);
}

}



3. Save the file with Student.java.


4. Compile and run the code using javac and java command on command prompt.





No comments:

Post a Comment

DBMS NOTES UNIT 3

                                                              UNIT 3  ER (Entity Relationship) An entity-relationship model is known as an E...