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.




Comments

Popular posts from this blog

Java Project Code: Cinema Ticket booking system : Create a Java Application to book a ticket in a Cinema hall.