×

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 15 Hadoop Interview Questions for 2024

1) What is Hadoop? Hadoop is a framework which is used to store and process Big Data. It is a distributed computing platform and helps in analyzing Big Data. 2) What are the...

2 minutes read.

Top 24 Clojure Interview Questions for 2024

1) What is Clojure? Clojure is a dynamic, general-purpose programming language. It is simple, coherent and powerful tool. It is based on Lisp Programming language. 2) Which platform is used to run...

4 minutes read.

Top 30 Web2py Framework Interview Questions for 2024

1) What is Web2py Framework? Web2py is an open source web application framework. It is written in the Python programming language. It allows web developers to design and develop dynamic web...

7 minutes read.

Top 15 Java BeanUtils Interview Questions for 2024

1) What is Java BeanUtils? Java BeanUtils is a design pattern component of the Apache Commons. It facilitates architecture for Java language which is derived from JavaAPI. It helps to set...

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.

Top 30 Magento Interview Questions for 2024

1) What is Magento? Magento is an open-source content management system. It is used to create e-commerce websites. It is developed by Varien ,Inc, a US private company headquartered in Culver City, California. It...

5 minutes read.

Top 16 WebGL Interview Questions for 2024

1) What is WebGL? WebGL stands for Web Graphics Library. It is a JavaScript API that is used for rendering 3D graphic in any compatible web browser. It is written in...

3 minutes read.

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...

4 minutes read.

Artificial Neural Network Interview Questions

1. Explain Neural Network?  Neural Network is a sequence of an algorithm that gives its best to recognize the underlying relationship in a data-set through a process. The artificial neural network...

8 minutes read.

Top 30 Joomla Interview Questions for 2024

1) What is Joomla? Joomla is an open source content management system. It is used to build online applications and websites. It uses model-view-controller (MVC) web application framework. It is free and easy to...

4 minutes read.

Top 25 DB2 Interview question for 2024

1) Give breif detail about DB2? DB2 is a Relational Database Management System developed by IBM. It supports Object Oriented features and non-relational structures with XML. 2) Enlist the types of datatypes...

3 minutes read.

PhoneGap Interview Questions 2024

Top 50 Phonegap Interview Questions with their Answers Once you have acquired practical knowledge of the PhoneGap technology, you will now be able to search for a job as a mobile...

9 minutes read.

Top 28 Angular 2 Interview Questions for 2024

1) What is Angular 2? It is an open source JavaScript framework which is used to build web applications in JavaScript and HTML. It is also used to overcome obstacles encountered while...

4 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.

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 15 Erlang Interview Questions for 2024

1) What is Erlang÷ Erlang is an open source programming language. It is used to build massively scalable soft real-time systems. It has runtime environment. It supports concurrency, fault tolerance and...

2 minutes read.

Top 30 PyTorch Interview Questions and Answers

Q1: What is PyTorch? Answer: PyTorch is a machine learning library for the programming language Python, based on Torch library, used for application such as natural language processing. It is free...

9 minutes read.

Top 30 Aurelia Interview Questions and Answers

1) What is Aurelia? Aurelia is an open source UI framework which is used for web and mobile app development. This framework is focused on web standards and follows simple conventions. 2) What...

2 minutes read.

Top 30 Less Interview Questions for 2024

1) What is Less? Less is a dynamic style sheet language that can be compiled in to CSS (Cascading style Sheet). It runs on client side and server side. It is...

4 minutes read.

Top 16 OpenStack Interview Questions for 2024

Most Frequently Asked OpenStack Interview Questions and Answers for Freshers 1. Describe OpenStack. OpenStack is designed as the future of cloud computing and developed as free and open-source software that facilitates a...

8 minutes read.