💻 Step 4:Classes and Objects : 2nd hour

Youtube-

💡Class

Definitions- 

💡 -> Class is a blueprint or template from which objects are created.

💡 -> Class is a logical representation of object.

💡 -> A class can have data members, objects, constructors, methods, nested classes etc

💡 -> Class doesn’t allocated memory when it is created.

💡 -> Class defines data members and methods which objects can implement.

Syntax –


class className{

}

 

💡Object

Definitions-

💡-> Object is an instance of a class

💡-> Object is considered as a real world thing.

💡-> Object is a physical entity.

💡-> Object uses data/state and methods/behaviour.

💡-> Object allocates memory when it is created.

Syntax(in general)-

ClassName objectName= new ConstructorName();

Note- ways to create object in java – new keyword(most popular), newInstance() method, clone() method, factory method and deserialization.
classes_and_objects

Interview Questions —

  • What is class in real world example?
  • Can object be created without class?
  • Who uses all methods and data defined in any class?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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