Java For Tester Interview
Java For Tester Interview
4 principles of OOPS
1. Encapsulation: Bundling data and methods within objects, hiding
implementation details.
2. Inheritance: Creating hierarchical relationships between classes to
promote code reuse.
3. Polymorphism: Treating objects of different classes as objects of a
common superclass, enabling flexibility and extensibility.
4. Abstraction: Focusing on essential features and hiding unnecessary
complexity
Class
1.Class: A class is a blueprint or template that defines the structure and
behavior of objects. It defines the properties (data) and methods
(functions) that objects of that class will possess.
Objects
• Object: An object is an instance of a class. It represents a specific
entity or occurrence based on the class blueprint. Each object has its
own set of data and can perform actions through its methods.
constructor
• A constructor in Java is a special method that is used to initialize
objects of a class.
• It has the same name as the class and does not have a return type.
• Constructors are called automatically when an object is created using
the "new" keyword.
Encapsulation
• Encapsulation: Encapsulation is the mechanism of hiding internal
details and providing a public interface to interact with objects. It
allows data to be accessed only through defined methods, ensuring
data integrity and security.
Inheritance
Inheritance is a mechanism where a class can inherit properties and
methods from another class.
It enables code reuse and promotes the hierarchical organization of
classes.
In Java, classes form an inheritance hierarchy through the "extends"
keyword.
polymorphism
Polymorphism allows objects of different classes to be treated as
objects of a common superclass.
It provides flexibility and extensibility by enabling the use of methods
defined in a superclass to be overridden in its subclasses.
Method Overloading & Overriding
• Method overloading occurs when multiple methods in the same class
have the same name but different parameters. The methods may have
different return types or different numbers/types of parameters.