01-February 2023
Training

10 most important Core Java Interview Questions with Answers

..
10 most important Core Java Interview Questions with Answers

 

Core Java Interview Questions with Answers

The questions of Core Java section are very common in the interviews of a Java Developer. There is a saying "One who is well versed with basic is ready for advanced challenges." These basic questions of Core Java asked in the beginning, later the questions of Advanced Java are asked to candidates. One should makes basics strong and these basic questions also makes one ready for in depth analysis. Go through these questions and make notes. Do share your experience of this article in the comment section. 

1. Arrays in java are

a) Object references                  

b) Objects

c) Primitive Data Type

d) None

 

2. When is the object created with new keyword?

a) At run time                                                

b) At compile time

c) Depends on the code

d) None

 

3. Identify the corrected definition of a package.

a) A package is a collection of editing tools

b) A package is a collection of classes

c) A package is a collection of classes and interfaces

d) A package is a collection of interfaces

 

4. Three editions of Java are

a) Java Standard Edition                            

b) Java Enterprise Edition

c) Java Micro Edition

d) All of the above

 

5. Java Architecture consists of

a) JVM                                              

b) JRE

c) JDK

d) All of the above

 

6. Which among the following is real world entity?

a) Class                                             

b) Object

c) Methods

d) Abstraction

 

7. Identify the output of the following program.

public class PrintMessage{

public static void main(String args[]){

                   String str1 = “INSPIRON”;

                   String str2 = “TECHNOLOGIES”;

                   System.out.println(str1.concat(str2));

          }

}

a) INSPIRON                                   

b) TECHNOLOGIES

c) TECHNOLOGIESINSPIRON

d) INSPIRONTECHNOLOGIES

 

8. replace() method in java returns NullPointerException if the replacement or the target is

a) 0                                     

b) null

c) repeated

d) None of the above

 

9. What does the following string do to given string val1.

String val1 = “InspironTechnologies”.replace(‘i’,’r’);

a) Replaces single occurrence of i to r.                

b) Replaces all occurrences of i to r.

c) replaces single occurrences of r to i

d) replaces all occurrences of r to i

 

10. To which of the following does the class string belong to?

a) Java.lang                                     

b) Java.awt

c) java.applet

d) java.string

Correct Answers of Core Java Interview Questions with Explanation

1. Answer: b)

Explanation: Arrays are objects in java. It is a container that holds a fixed number of items of a single type.

 

2. Answer: a)

Explanation: The object created with new keyword during run-time.

 

3. Answer: c)

Explanation: A package is a collection of classes and interfaces.

 

4. Answer: d)

Explanation:

 

5. Answer: d)

Explanation: Java Architecture consists of mainly three components i.e. JVM, JDK, JRE

 

6. Answer: b)

Explanation: Object is the real world entity. Class is the collection of similar objects.

 

7. Answer: d) INSPIRONTECHNOLOGIES

Explanation: The Java String class concat() method combines specified string at the end of this string. It returns a combined string. It is like appending another string.

 

8. Answer: b) null

NullPointerException: if the replacement or target is equal to null.

 

9. Answer: b)

Explanation: replace() replaces all the occurrences of the oldcharacter by the newcharacter.

 

10. Answer: a) java.lang

 

We hope that you must have found this exercise quite useful. If you wish to join Core Java, Advance Java, Spring Boot Framework, Struts Framework training, feel free to contact us at +91-9936804420 or email us at aditya.inspiron@gmail.com. 

Happy Learning 

Team Inspiron Technologies 

Explanation: string class belongs to java.lang package.

Leave a comment

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