22 Aug
|
StudyECart Technologies
|
India
22 Aug
StudyECart Technologies
India
Explain the four pillars of Object-Oriented Programming (OOP).
Answer:
The four pillars of OOP are:
Encapsulation: Wrapping data and methods into a single unit (class).
Inheritance: Mechanism where one class inherits the properties and behavior of another class.
Polymorphism: Ability of a class to take many forms, typically through method overriding and overloading.
Abstraction: Hiding implementation details and exposing only the essential features of an object.
What is the difference between final, finalize, and finally in Java?
Answer:
final: Used to declare constants, prevent method overriding, and prevent inheritance of classes.
finalize: A method in the Object class used for garbage collection before the object is destroyed.
finally: A block used for code that must be executed regardless of whether an exception occurs or not.
Explain the difference between == and equals() in Java.
Answer:
== compares object references (memory locations), whereas equals() compares the actual content or state of the objects.
What is the difference between method overloading and method overriding?
Answer:
Overloading: Defining multiple methods with the same name but different parameter lists within the same class.
Overriding: Redefining a method in a subclass that already exists in the superclass, to provide a specific implementation.
What is polymorphism in Java, and how is it implemented?
Answer:
Polymorphism allows objects of different classes to be treated as objects of a common superclass. It is implemented through method overriding and method overloading.
What is the use of the super keyword in Java?
Answer:
The super keyword is used to refer to the superclass of the current object. It is used to call superclass methods, constructors, or access superclass variables.
Can you explain Java's access modifiers (private, protected, default, and public)?
Answer:
private: Restricts access to the member within the same class.
protected: Allo
📌 Birdeye Top 20 Java Developer Interview Questions 0 3 Years Experience Bengaluru (India)
🏢 StudyECart Technologies
📍 India