Java OOP Interview Question

Java OOP Interview Question set3

What is class?

A class is the blueprint or template which defines the state or behavior that object of its type will support.

In java, we cannot write any piece of code without using class. A class is the basic neccesity for writing a java code.


Given below is an example demonstrating the way java defines class:

public class DemoExample {

//write your code here

class keywords indicates that we are creating a class.

Here 'DemoExample' is the name of the class. You may name it anything as per your wish.

Once you have declared your class, you can write methods, create instances of other classes, invoke other class, print values and do unlimited things.


To read in details about both the class and object go to our java tutorials class and object chapter

What is object?

In the above question, we learnt that a class is a template or blueprint.


We can create any number of object or instance using this template. 


So if class is a template then object is the instance of the class

Follow the link provided in first question to read in detail about class and object together.

What is abstraction?

Abstraction means the situation in which the subject is very general and not based on the real situation. Abstract information is general idea or term.

Abstraction is one of the key principal of OOP.


Abstract idea shows only the necessary details and hides the unwanted details from the user.

For example, while driving a car you know the outer features like what applying break, changing gears, etc would do but you are not required to know how they work or what process they follow to accomplish their task. This in turn reduces the driver’s complexity and increases his efficiency


Learn in depth about abstraction here

How is abstraction achieved in java?

Abstraction can be achieved in following ways:

  1. Abstract class → Abstract class helps in achieving partial abstraction.
  2. Interface → Interface helps achieve complete or 100% abstraction.

What is abstract class?

An abstract class is a class that may contain both concrete method as well as abstract method.

Abstract class helps in achieving partial abstraction in java.


To declare a class as abstract, you need to use abstract keyword as shown below:

abstract class AbstractDemo {


If a class contains even a single abstract method it must be declared abstract.


Learn in depth about abstract class in our java tutorial here




Please Share this page
Views : 63
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!