×

Top 15 Java OOPS Interview Questions for 2024

1) What are the advantages of Java Package?

Advantages of Java package are:
  • Provides access protection
  • Removes naming collision
  • Easily maintained

2) What are the types of Access Modifiers in Java?

Two types of Access Modifiers in Java are: 1) access modifiers
  • private
  • default
  • protected
  • public
2) non-access modifiers
  • static
  • abstract
  • synchronized
  • native
  • volatile
  • transient etc

3) What are the types of constructors in Java?

Two types of constructors in java are :
  • Default constructor
  • Parameterized constructor

4) What is the difference between constructor and method in Java?

Differnce between constructor and method :
Constructor Method
It is used to initialize the state of an object It is used to expose behaviour of an object
Invoked implicitly Invoked explicitly
Must not have return type Must have return type
It's name must be same as the class name. It's name may or may not be same as class name.

5) What are the different oops concept in Java?

The different oops concepts are :
  • Polymorphism
  • Inheritance
  • Encapsulation
  • Abstraction
  • Composition
  • Association
  • Aggregation

6) What are the restrictions of static method in Java?

Two main restrictions of static method are:
  • It can't use non static data member
  • super and this can't be used in static context

7) What will be the output of following piece of code?

class TutorialExam  
{    
int b=98;   
public static void main(String args[])  
{    
System.out.println(b);    
}    
}
OUTPUT:
Compile Time Error

8) Can we override java main method?

We can't override main method in java because main method is static.

9) Write a program in java for Single inheritance ?

Example of Single inheritance:
class Mom{    
void eat()  
{  
System.out.println("eating...");  
}    
}    
class Baby extends Mom  
{    
void run()  
{  
System.out.println("Running...");  
}    
}    
class TutorialExam{    
public static void main(String args[]){    
Baby b=new Baby();    
b.run();    
b.eat();    
}  
}

10) What are the types of inheritance in Java?

There are five types of inheritance in java:
  • Single inheritance
  • Multilevel inheritance
  • Hierarchical inheritance
  • Multiple inheritance
  • Hybrid inheritance

11) Write a program in java of super keyword where super() is provided by the compiler implicitly?

Example:
class Cars  
{    
Cars()  
{  
System.out.println("Choose a car : BMW, AUDI, JAGUAR");  
}    
}    
class BMW extends Cars  
{    
BMW()  
{    
System.out.println("Selected car :BMW");    
}    
}    
class TestCars  
{    
public static void main(String args[])  
{    
BMW d=new BMW();    
}  
}

12) Write a program in java of Runtime polymorphism?

Example of Runtime Polymorphism:
class Car  
{    
void run()  
{  
System.out.println("Running");  
}    
}    
class Audi extends Car  
{    
void run()  
{  
System.out.println("Running with 150km/h");  
}    
public static void main(String args[])  
{    
Car c = new Audi();    
c.run();    
}    
}

13) What are the types of binding in Java?

Two types of binding in java are:
  • Static binding(early binding)
  • Dynamic binding(late binding)

14) What are the ways to achieve Abstraction in Java?

Two ways to achieve abstraction in java:
  • By using Abstract class
  • By using Interface

15) What are the commonly used methods of Object class in Java?

Commonly used methods of Object class in java are:
  • public int hashCode()
  • public String toString()
  • public final void notify()
  • public final void notifyAll()
  • public final Class getClass()
  • public boolean equals(Object obj)
  • protected void finalize()throws Throwable
  • public final void wait()throws InterruptedException
  • protected Object clone() throws CloneNotSupportedException
  • public final void wait(long timeout)throws InterruptedException
  • public final void wait(long timeout, int nanos)throws InterruptedException

Related Topics

Top 10 Java Swing Interview Questions for 2024

1) What is Java Swing? It is a part of JFC (Java Foundation Classess) that is used to create window-based applications. Java Swing components are platform independent and lightweight . 2) What is...

3 minutes read.

Top 25 MongoDB interview Questions for 2024

1) Give some history about MongoDB. MongoDB came into existence when data increased exponentially on the internet. Thus, maintainence of database became very difficult in structured DB. MongoDB is a NoSQL...

3 minutes read.

Top 50 HTML Interview Questions for 2024

1) What is HTML? HTML stands for Hyper Text Markup Language. It is used for creating web pages and web applications. HTML documents are made up of two things: the content and the tags. 2) What are...

10 minutes read.

Top 25 Android Interview Questions for 2024

1) What is Android? It is a software package and open-source operating system that is used in mobile devices. It is also a Linux kernel-based system operating system and application executes within...

3 minutes read.

A to Z Interview Questions

ABCDEFGHIJKLMNOPQRSTUVWXYZ Interview Questions and Answers List A AJAX Interview Questions Android Interview Questions Angular 2 Interview Questions AngularJs Interview Questions Apache Presto Interview Questions Apache Tapestry Interview Questions Arduino Interview Questions ASP.NET MVC Interview Questions Aurelia Interview Questions AWS Interview Questions B Blockchain Interview...

3 minutes read.

SSIS Interview Questions and Answers

Q.1 What is SSIS? SQL Server Integration Service (SSIS) is a component of Microsoft SQL Server. It is a powerful ETL tool that is used for building enterprise-level data transformation and...

5 minutes read.

Top 20 C Programming | Coding Interview Questions for 2024

Most Frequently asked C programming | Coding Interview Questions and answer for Fresher C is a powerful high-level programming language.  It is a fast, portable and available for all platforms. C...

15 minutes read.

Top 27 JavaScript Interview Questions for 2024

1) Define Undeclared and Undefined Variables? Undeclared variable are defined as these variable is neither defined nor exist in the program. If program calls this variable then it causes Runtime error. Undefined variable...

5 minutes read.

Top 32 Laravel Interview Questions for 2024

1) What is Laravel? Laravel is an open source PHP framework. It is used to design and develop web applications. It is based on MVC (Model-View-Controller) design pattern. It is created by Taylor...

6 minutes read.

Top 15 XHTML Interview Questions for 202

1) What is XHTML? XHTML (Extensible Hyper Text Markup Language) it is similar to the HTML but has some strict rule than HTML. It is said to be HTML defined as...

3 minutes read.

Polymer.js Interview Questions

1) What is Polymer.js? Polymer.js is an open source JavaScript library. It is developed by Google. It is used to develop web applications for using of web components like HTML. 2) Describe...

3 minutes read.

Top 15 SQL Server Interview Question for 2024

1) Describe SQL Server? SQL server is a DataBase Management System developed by Microsoft. It was first introduced in year 2008 since, then many version has been introduced such as :...

2 minutes read.

Top 15 PouchDB Interview Questions for 2024

1) What is PouchDB? PouchDB is an in-browser database that allows applications to save data. It is an open source database. It runs in Node.js. 2) In which language PouchDB was written? PouchDB was written in JavaScript language. 3)...

2 minutes read.

Top 30 Swift Interview Questions for 2024

1) What is Swift? It is an innovative programming language developed by Apple Inc. It is used for creating applications for iOS and OS X. 2) What are the features of Swift Programming? Features...

4 minutes read.

Top 14 MathML Interview Questions for 2024

1) What is MathML? MathL stands for Mathematical Markup Language. It is extended form of XML. It is used to describe mathematical and scientific notations. 2) Who is the developer of MathML? World...

3 minutes read.

Top 18 UiPath Interview Questions for 2024

RPA UiPath Interview Questions and Answers for Fresher  1. What is RPA? RPA is an acronym for Robotic Process Automation. Robotic In RPA, Robotic is termed as an entity or machine which tries to...

7 minutes read.

Top 15 Struts Interview Questions for 2024

1) What are the Features of Struts 2? Features of Struts 2 are: Configurable MVC components POJO based actions AJAX support Integration support Various Result Types Various Tag support Theme and...

3 minutes read.

Top 15 SVG Interview Questions for 2024

1) What is SVG? SVG stands for Scalable Vector Graphics, It is XML based format used to draw dimentional vector images. It is a W3C standard. SVG supports all image formats. 2) What are...

2 minutes read.

Top 40 TensorFlow Interview Questions and Answers

Commonly Asked TensorFlow Interview Questions for Fresher Q1. What is TensorFlow? TensorFlow is the machine learning library developed by Google's brain team, it supports multiple abstraction levels, and we can choose the...

13 minutes read.

Top 22 MariaDB Interview Question for 2024

1) What is MariaDB? It is a community based database devoloped by MySQL Devolopers. It provides same features as MySQL also, can be said that it is a replacement of MySQL. 2)...

3 minutes read.