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....
2. Principles of OOP.
The below are the principles that attributes to the OOP behavior. Inheritance Abstraction Encapsulation Polymorphism Aggregation Composition Association
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.
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.
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....
6. Object.
"Object" refers to an instance of a class where the object can contain any combination of variables, functions.
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.
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.
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....
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.
11. Differences Between Static Binding And Dynamic Binding In Java.
Static Binding. Dynamic Binding....
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.
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...
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,...
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.
16. Which of the Java OOPS feature promotes access protection or data hiding?
Encapsulation promotes access protection and data hiding.
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.
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....