An object is defined as an element that a user creates. It has a certain state and behavior which is stored in variables (fields) and methods (functions) display the object’s behavior.

An object consists of: 1)State (reflects properties of objects; represented by attributes); 2)Behavior (represented by methods of object; also reflects response by other objects); 3)Identity (gives an unique name to each object; enables one object to interact with another object)

VIDEO LINKS ABOUT OBJECTS:

14 minute video in detail about objects

When an object of a class is created, we say the class to be instantiated. All instances of a class share the same attributes and the behavior of the class. Another thing is that a class can have any number of instances.

How to Instantiate an Object: ObjectType objectName = new ObjectType();

E.x. String sai = new String(); [This creates a new string object called sai.]; Similarly, there can be int hello = new int(); [IT IS IMPORTANT TO HAVE THE PARENTHESES with a semicolon!]

For every line of code you type in a class, A SEMICOLON AT THE END IS REQUIRED!!

Here is a link to a detailed website about Objects and Classes: https://www.javatpoint.com/object-and-class-in-java

LINK with sample PROGRAMS WITH OBJECTS: https://www.programiz.com/java-programming/class-objects

Copyright © 2020 — Mins WordPress theme by GoDaddy