Interview Question

Java interview questions and answers for freshers or experienced | SCODES – Solution Codes

Basic or Core Java Interview questions: 

Java interview questions and answers for freshers or experienced | SCODES - Solution Codes

1. Explain how Java is not a pure OOP or Object-oriented language?

Boolean, Byte, Short, Char, Int, Float, Long, and Double is not a pure object-oriented language. and Java supports all these primitive data types.

2. What condition do you use for an infinite loop in Java?

An infinite loop is a loop that runs continuously without breaking conditions. Let’s look at some examples of infinite loops:

With for loop:

  for(;;)
{
//Add programming logic
}

With while loop:

  
while(true){
// Add programming logic
}

With do-while loop:

 
do{
// Add programming logic
}while(true);

3. What is Constructor overloading

Constructor Overloading means more than one constructor with the same name, but each constructor with different parameters.

 	class Vehicles{
int var1, var2;
double var3;

public Vehicles(int type, int number){
var1 = type;
var2 = number;
}

public Vehicles(int type){
var1 = type;
}

public Vehicles(double price){
var3 = price;
}
}

In this example, the class vehicle consists of three same name constructors, but it has different-different parameters.

5. Define ClassLoader in java?

In Java a classloader is a subsystem of JVM (Java Virtual Machine), dedicated to loading class files when a program is executed; ClassLoader loads the executable file.

Java has Bootstrap, Extension, and Application classloaders.

6. Method overloading and

In Java a classloader is a subsystem of JVM (Java Virtual Machine), dedicated to loading class files when a program is executed; ClassLoader loads the executable file.

Java has Bootstrap, Extension, and Application classloaders.

7. What is Scope in java?

Variables that are only operated or accessed in the region they created are called Scope.

public class Main {

  public static void main(String[] args) {

    // Code here cannot use x

    int x = 100;

    // Code here can use x

    System.out.println(x);

  }

}

gp

Are you looking to learn a programming language but feeling overwhelmed by the complexity? Our programming language guide provides an easy-to-understand, step-by-step approach to mastering programming.

Leave a Reply

Your email address will not be published. Required fields are marked *