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

Empowering Technology

Post Top Ad

Responsive Ads Here

Mar 25, 2018

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 >>>

No comments:

Post a Comment

Thanks a lot for your valuable Comment!

Post Bottom Ad

Responsive Ads Here