Object Declaration and Access Class Members in JAVA

Object declaration is necessary to access class members in JAVA. From previous video you have learned how to declare class in JAVA (). This video will teach you the way to declare an object of a class, initialize it with the help of new keyword and finally access class members.

After watching this video you will be able to-

  • Write main function in class.
  • Declare an object of a class.
  • Instantiate object.
  • Access class members using object.
  • Explain the use of dot operator.
  • Explain the use of new keyword.
  • Initialize the property of class in class declaration

Syntax to declare an object for a class:-

<class_name> <object_name>;

new keyword is used to instantiate class object. Syntax to instantiate an object is:

<object_name> = new <class_name>

dot (.) operator is required to access class members using object. Syntax to access a class member is:


class employee
	  int empID=5;
	  void showEmpID()
	  public static void main(String args[])
		  employee e; // object declaration
		  e=new employee();


Vineet Agrawal

An educational consultant Vineet Agrawal is a director and founder of Solution Center, Agra. He has been providing training for last 17 years. He has trained 1000s of students of the software industry. He has been actively involved in final year projects of B.Tech. (CS /IT). The programs included in this video series are based on his experience of teaching that will help you in cracking a java interview.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu


Close Panel
Skip to toolbar