Basic Java for Testers | Ch-6 | Classes and Objects in Java

Reading time : 5 Minutes

Previous Chapter >>>> Ch-5 Loops in Java 

Classes and Objects in Java

Classes and Objects play a key role in every Object Oriented programming language. 
Classes lets us group simple data structures and create complex data structures.

Objects in Java?
Object Oriented Programming defines an object as an instance of a class. An object can be anything like a car, dog, door window etc. which performs certain activities. 
Objects have two mandatory characteristics: state and behavior.
For example: A motorbike has state (brand, color, model etc.) and behavior (braking, accelerating etc).

In programming languages objects maintain state in variables and executes its behavior using methods. So from  above example can say that an object Motorbike is a collection of methods ( behavior – braking, accelerating)   and variables (state – make, brand, color etc.).

Classes in Java?
Classes are the blueprints for creating objects. By blueprints, it means classes always have same structure and implementation.
Class is created while creating program whereas, objects are created at run-time.

Sample program illustrating use of Classes and Objects in Java:

Next Chapter >>>

Basic Java for Testers | Ch-6 | Classes and Objects in Java Basic Java for Testers | Ch-6 | Classes and Objects in Java Reviewed by Ishan Dev Shukl on March 25, 2018 Rating: 5

No comments:

Thanks a lot for your valuable Comment!

Powered by Blogger.