Ads Area

Basic Java Interview Question and Answers

Download JAVA Frequently Ask IMP Notes !

Steps to Download PDF File

  1. Click on download link.
  2. Then page redirect to Rozorpay 3rd part website , then enter your Email, phone number and click on pay button.
  3. Select the payment method like Card, UPI, Wallet, Net Banking and pay the amount.

JAVA frequently ask and very important Interview Questions and Answer Download Now Only at  20 Rs + Free Job Updates still placement (purchase any pdf).

Java Questions & Answers

Click & Download

Automation Software Testing 

Click & Download

Wish you all the best and Happy learning !

Following are Sample Questions and Answers from PDF

1) What is minimum requirement to run the java program => jvm, jdk and jre ?

- JDK is required, because it include JRE and some other files too

2) What is the constructor in java?

1. Constructor name always same as your class name.

2. Constructor is used only to initialize your object.

3. Constructor is used at the time of object creation

i.e suppose your class name is God and you create its object ganpati

Syntax:  

God ganpati = new God();  

When above statement create constructor gets called automatically.

4. Constructor never be inherited.

Types of Constructor:

a. Simple constructor

b. Parameterized constructor

c. Copy Constructor

3) Constructor return any value?

Constructor cannot return any value, it does not have any return type

4) Can we make a constructor final?

- Final means cannot be change once it’s initialized, so use final keyword with constructor could cause a problem.

- The constructor cannot be final because the constructor cannot be inherited and in constructor values are initialized to the variable so by this variables changes every time.

- A constructor can’t inherited so can’t be overridden(Same method name with same parameter) , so there is no use of making constructor final.

5) What is static in java?

Static is a non-access modifier in java which is applicable for the following

a. Blocks

b. Variables

c. Method

d. Nested classes

6) Why main method is static in java?

Public static void main(String[] args)

{

System.out.println(“Hello);

}

- Main method is static in java because main() is called by the JVM, before any objects are made so it’s static method

- Static method can be directly called by the class not need to create object

7) Can we override a static method?

- We cannot override static method java.

- If a derived class defined static method with same signature as static method in base class, then method in the derived class hides the method in the base class

8) Inheritance in java?

- Inheritance is one class acquires the properties (data members) and functionalities (Method) of another class is called inheritance.

- Object which acquired the properties of another object is called inheritance. Properties means code & data / method & fields.

Type of Inheritance

a. Single Inheritance

b. Multilevel Inheritance

c. Hierarchical Inheritance

d. Hybrid Inheritance

9) Why multiple Inheritance is not possible java?

- Java not support multiple inheritance.

- Suppose Z is the child class extending from both parent class X and parent class Y with same method defined in them. Then child class not understand which class method to call. So there is confusion which class method is call so compile time error is occurs.

i.e.

Class Ganpati

{

Void msg();

}

Class Krushna

{

Void msg();

}

Class God extends Ganpati, Krushna

{

} (not allowed)

Class God extends Ganpati (allowed)

- Java does not support multiple inheritance so java used interface

10) Why java is not 100 % object-oriented?

- Because of the primitive data type namely java is not 100% OOP

- Boolean, byte, char, int, float, double, short, long use in java

****************************Next 10 Question Update Tomorrow**********************