0% found this document useful (0 votes)
3 views2 pages

Java Interviews

The document outlines key concepts in Java programming, including Method Overloading, Method Overriding, Dynamic Method Dispatch, Encapsulation, and Abstraction. It explains the differences between method overloading and overriding, emphasizing compile-time versus runtime polymorphism. Additionally, it illustrates encapsulation and abstraction with relatable examples to clarify these concepts.

Uploaded by

er.s.abbas003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Interviews

The document outlines key concepts in Java programming, including Method Overloading, Method Overriding, Dynamic Method Dispatch, Encapsulation, and Abstraction. It explains the differences between method overloading and overriding, emphasizing compile-time versus runtime polymorphism. Additionally, it illustrates encapsulation and abstraction with relatable examples to clarify these concepts.

Uploaded by

er.s.abbas003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

JAVA

INTERVIEWS
1. Method Overloading
Method Overloading is the process of defining multiple methods in the same class with the
same name but different parameters. (Also called Static Binding, Static Polymorphism, Early
Binding).

2. Method Overriding
Method Overriding is the process of defining a method in a child class that already exists in the
parent class with the same method name and same parameters. (Also called Dynamic Binding,
Dynamic Polymorphism, Late Binding, Dynamic Method Dispatch). (The compiler checks the
reference type at compile time, but the JVM executes the object type method at runtime).

3. Dynamic Method Dispatch


Dynamic Method Dispatch is the process where the JVM decides which overridden method to
execute at runtime based on the actual object type.

4. Difference between Method Overloading and Method Overriding

Overloading Overriding
Same method name, different parameters Same method name, same parameters

Happens in same class Happens in parent-child classes

Compile-time polymorphism Runtime polymorphism

Decided by compiler Decided by JVM at runtime

5. Encapsulation
Encapsulation is the process of providing security to the most important part of an object, which
is the data members. This is achieved by declaring variables as private and providing controlled
access using public getter and setter methods.

Example,
In a shop the products are kept inside a locked cupboard. Customers cannot access the
products directly. The shopkeeper opens the cupboard using a key and provides the product.
Similarly in Java, variables are kept private and accessed through public getter and setter
methods. This concept is called encapsulation.

6. Abstraction
Abstraction is the process of hiding the internal implementation details and showing only the
essential functionality to the user.

Example,

When we use an ATM machine, we insert the card and enter the PIN to withdraw money. We do
not know how the ATM processes the transaction internally. The system only shows the required
functionality to the user.

When we use a camera to take a photo, we just press the capture button without knowing how
the internal system works. The camera hides the internal implementation and shows only the
functionality to the user.

You might also like