Prev Next

Java / OOPS Concepts and its implementation in Java

1. OOP.

Object Oriented programming is a type of programming paradigm where programs are treated as real-world objects. OOPS correlates a computer program into a real-world object. A real-world object, for example, a car, has properties and its associated behaviors. Car has wheels as property and its ass...

Read full answer

2. Principles of OOP.

The below are the principles that attributes to the OOP behavior. Inheritance Abstraction Encapsulation Polymorphism Aggregation Composition Association

Read full answer

3. Open closed principle.

In object oriented programming world, the open-closed principle states that the software components classes, methods etc should be open for extension but closed for modification. A class can allow its behavior to be extended without modifying its own behavior.

Read full answer

4. Difference between object oriented and object based language.

Object oriented language supports all the features/principles of OOP whereas object-based languages do not support all the features. e.g. Javascript does not support inheritance and polymorphism. C++, Java are examples of object-oriented and Javascript and VB are object-based.

Read full answer

5. Define class.

A class is a blueprint/prototype or a template for creating different objects which define its properties and behaviors. Java class objects exhibit the properties and behaviors defined by its class. A class provides fields and methods that describe the behavior of an object. The cast in the below...

Read full answer

6. Object.

"Object" refers to an instance of a class where the object can contain any combination of variables, functions.

Read full answer

7. Define a variable/data.

A variable holds or stores some data; one variable might be a color of car, another variable might be model.

Read full answer

8. Explain Diamond problem.

The diamond problem (a.k.a deadly diamond of death) refers to an ambiguity that brews due to allowing multiple inheritance. In Java, multiple inheritance is not allowed for classes and permitted only for interfaces to eliminates this serious issue.

Read full answer

9. SOLID principles of OOD (Object Oriented Design).

SOLID principles provide the specification for the design of a class to ensure high quality. There are five principles as each letter in SOLID represents one. The Single Responsibility Principle. Every class should only serve a single purpose and that responsibility be encapsulated at the same cl...

Read full answer

10. Why Java does not support operator overloading?

Operator overloading makes the code less readable and poorly maintainable. To maintain code simplicity, Java doesn't support operator overloading.

Read full answer

11. Differences Between Static Binding And Dynamic Binding In Java.

Static Binding. Dynamic Binding. binding that happens at compile time . binding that happens at run time . Actual object is not used for binding. Actual object is used for binding. Method overloading is the best example of static binding. Method overriding is the best example of dynamic binding. ...

Read full answer

12. In a class, a method is overloaded and One form is declared static while another form is non-static. Is that method properly overloaded?

Yes. Compiler checks only method signature to validate if a particular method is overloaded or not. It does not check static or non-static nature of the method.

Read full answer

13. What is Encapsulation in Java?

Encapsulation in Java is a concept that enforces protecting variables, functions from outside of class, in order to better manage that piece of code and having least impact or no impact on other parts of a program due to change in protected code. You can completely encapsulate a member be it a va...

Read full answer

14. Difference between data hiding and data abstraction in OOPS.

Data hiding is when the designer specifically decides to limit access to details of an implementation. Abstraction is when you are dealing with an aggregate, for example, a Car is an abstraction of details such as a Motor, Wheels, brake, etc. Abstractions allow us to think of complex things in a ...

Read full answer

15. Difference between abstraction and encapsulation in OOPS.

Abstraction deals with separating interface from implementation. Abstraction in java is achieved by using interface and abstract class. Interface ensures 100% abstraction and abstract class provide 0-100% abstraction. Encapsulation restricts access to or knowledge of internal structures of an imp...

Read full answer

16. Which of the Java OOPS feature promotes access protection or data hiding?

Encapsulation promotes access protection and data hiding.

Read full answer

17. Explain Liskov Substitution Principle (LSP).

The Liskov Substitution Principle is a concept in Object Oriented Programming that states: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.

Read full answer

18. Explain cohesion and coupling in OOD.

Cohesion refers to what the class (or module) can do. High cohesion is preferred since it is focused on actions it can perform and limited. Lower cohesion means that the class does a great variety of actions, broad, unfocused. Coupling refers to how related or dependent two classes/modules are to...

Read full answer

«
»

Comments & Discussions