Interview Questions on OOPS Using Java
Interview Questions on OOPS Using Java
3. reducing redundancy
4. encapsulation
5. data hiding
Providing public getter and setter methods to access and update the private fields.
Compile-time/
Checked at compile-time Checked at runtime
Runtime
5. Define protected access modifier.
A protected access modifier is accessible by own class and accessible by derived class but
not accessible by the world.
8. How can you call a base class method without creating an instance?
It is possible to call the base class without instantiation if it’s a static method and some other
subclass has inherited the base class.
9. One of the key OOPs interview questions could be to give a real-life example of data
abstraction.
While driving a car, you know that on pressing the accelerator, the speed will increase.
However, you do not know precisely how it happens. This is an example of data abstraction
as the implementation details are concealed from the driver.
13. What are some other programming paradigms other than OOPs?
Other programming paradigms include:
Event-driven Programming: This emphasizes handling events, and the control flow is
based on the events.
The parent class is a logical concept, such as a vehicle is a base class that defines the
common properties shared by all vehicles. However, child classes are a more specific type
of class such as truck, bus, car, etc. Inheritance allows subclasses to inherit common
attributes of a vehicle and define specific attributes and methods to their own.
The size of a class is the sum of the dimensions of all its data members. For example, a class
with an int data member and a double data member would occupy 8 bytes on a system with
4-byte ints and 8-byte doubles.
The significance of access specifiers is to control the visibility and accessibility of class
members, preventing unintended modification and promoting encapsulation.
35. Can we run a Java application without implementing the OOPs concept?
No, Java is an object-oriented programming language, and the core concepts of OOPs, such
as classes, objects, and inheritance, are fundamental to the language.