Our Blog

BY : developer 0 comment

Selected Java Interview Questions Part – 2

8)What is method overriding?

If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding. It is used for runtime polymorphism and to provide the specific implementation of the method.


class Vehicle{
void run(){System.out.println(“Vehicle is running”); }}
class Bike2 extends Vehicle{
void run(){System.out.println(“Bike is running safely”);}
public static void main(String args[]){
Bike2 obj = new Bike2();


Bike is running safely

9) Difference between method Overloading and Overriding.

Method Overloading:

1)    Method overloading increases the readability of the program.
2)    method overlaoding is occurs within the class.
3)    In this case, parameter must be different.

Method Overriding:

1)    Method overriding provides the specific implementation of the method that is already provided by its super class.
2)    Method overriding occurs in two classes that have IS-A relationship
3)    In this case, parameter must be same.

10) What is Runtime Polymorphism?

Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time.

In this process, an overridden method is called through the reference variable of a super class. The determination of the method to be called is based on the object being referred to by the reference variable.


class Bike{
void run(){System.out.println(“running”); }}
class Splender extends Bike{
void run(){System.out.println(“running safely with 60km”);}
public static void main(String args[]){
Bike b = new Splender();//upcasting


Running safely with 60km

11) What is the difference between static binding and dynamic binding?

In case of static binding type of object is determined at compile time whereas in dynamic binding type of object is determined at runtime.

Eg for static binding:

class Dog{
private void eat(){System.out.println(“dog is eating…”);}
public static void main(String args[]){
Dog d1=new Dog();

Eg for dynamic binding:

class Animal{
void eat(){System.out.println(“animal is eating…”); }}
class Dog extends Animal{
void eat(){System.out.println(“dog is eating…”);}
public static void main(String args[]){
Animal a=new Dog();


dog is eating…

12) What is abstraction?

Abstraction is a process of hiding the implementation details and showing only functionality to the user.


abstract class Bike{
abstract void run();
class Honda4 extends Bike{
void run(){System.out.println(“running safely..”);}
public static void main(String args[]){
Bike obj = new Honda4();


Running safely

13) What is the difference between abstraction and encapsulation?

Abstraction hides the implementation details whereas encapsulation wraps code and data into a single unit.

14) What is interface?

Interface is a blueprint of a class that have static constants and abstract methods.It can be used to achieve fully abstraction and multiple inheritance.


interface printable{
void print();
class A6 implements printable{
public void print(){System.out.println(“Hello”);}
public static void main(String args[]){
A6 obj = new A6();



15) What is difference between abstract class and interface?

Abstract class:

1)  An abstract class can have method body (non-abstract methods).
2)  An abstract class can have instance variables.
3)  An abstract class can have constructor.
4)  An abstract class can have static methods
5)  You can extends one abstract class.


1)    Interface have only abstract methods.
2)    An interface cannot have instance variables.
3)    Interface cannot have constructor.
4)    Interface cannot have static methods.
5)    You can implement multiple interfaces.

Rudit Mathews | Java + Android Student ( IT FINISHING SCHOOL) | IPSR INTERNATIONAL CENTRE, KOCHI ( Edappally)

List of Authors

Leave a Reply

Your email address will not be published.


#aintegrateddigitlmarketing##ansibleautomates#AWS#blog#cicd#Container#DO180#DO280#ipsronlinetraining#kubernetes#OpenShift#OpenShiftTraining#pythonindemand##redhatautomation#redhatcertification#redhatcertification #redhatlinux #redhatsystemadministration #ansibleautomates #containers #kubernetes #RHCSA #RHCE #DO180 #DO280 #ipsr #ipsronlinetraining #openshift#RedHatLearningSubscription#redhatlinux#RedHatOpenShift#redhatsystemadministration#RedHatTraining#RHCE#RHCSA#RHLS#RHLSPremium#tiktokanalyticsandroidansiblearticleArtificial IntelligenceASP.NETaws online trainingbacklinkboot campcareercareer advancementcareer opportunitycertificationcloudclougcontainerscybersecurityCyberSecurityCertificationData Analysts in 2024data analyticsdata analytics certificationdata analytics trainingdemandDev-OpsDevopDevOpsDigital marketingdigital marketing courseDigital Marketing Salary in IndiaExam resultsfiles typesForrester ResearchindiaInfluencer MarketingInstagraminterview questionsinterview quetioninterview techniqueIOTipsrITit careerIT Finishing schoolsIT jobsIT proffessionalsITFSjavajob interviewjob opportunitiesjob opportunitiessjobskeywordKMEA Collegelearn python onlinelink buildingLinuxlinux online trainingLinux System Administrationmachine learningMastering DevOpsnetworkingonline python trainingopen sourcephytonplacementsPrivate Cloudpythonpython certificationpython certification coursePython in 2024python trainingRankingsRed HatRed Hat Academyred hat linuxRed Hat Linux TrainingredhatresultsRHCARHCE certificationrolessocial media marketing online coursesoftwarestudent poststudents postsuccess storiestablueThreads by Instagramtraining