27-December 2022
Training

Core Java Interview Questions with Answers

..
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 worsed 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 analyis. Go through these questions and make notes. Do share your experience of this article in the comment section. 

 

1. Which statement is true about Java?

a) Java is a sequence-dependent programming language

b) Java is a code dependent programming language

c) Java is a platform-dependent programming language

d) Java is a platform-independent programming language

 

2. Find the output of the following program.

public class Solution{

       public static void main(String[] args){

                     byte x = 127;

                     x++;

                     x++;

                     System.out.print(x);

       }

}

a) -127                                              

b) 127                       

c) 129

d) 2

 

3. Number of primitive data types in Java are

a) 6                                     

b) 7              

c) 8

d) 9

 

4. What is the size of float and double in java?

a) 64 and 64                    

b) 32 and 64          

c) 64 and 32

d) 32 and 32

 

5. Select the valid statement.

a) char[] ch= new char(4)

b) char[] ch= new char[4]

c) char[] ch= new char()

d) char[] ch= new char[]

 

6. Automatic type conversion is possible in?

a) Byte to int                  

b) Int to long             

c) long to int

d) short to int

 

7. Find the output of the following code.

int Integer = 32;

char String  = ‘INSPIRON’;

System.out.print(Integer);

System.out.print(String);

a) INSPIRON                                   

b) 32 INSPIRON                             

c) Compilation Error

d) Exception

 

8. What is the output of the following program.

public class Solution{

       public static void main(String[] args){

                     short j = 5;

                     x =  x * 2;

                     System.out.print(x);

       }

}

a) 50                                  

b) 10                                  

c) Compile Error

d) Exception

 

9. Find the output of the following program.

public class Solution{

       public static void main(String[] args){

                     byte x = 90;

                     x++;

                     x++;

                     System.out.print(x);

       }

}

a) 90                                  

b) 91    

c) 92

d) 93

 

10. When an array is passed to a method, what does the method receive?

a) The reference of the array         

b) A copy of the array                     

c) Length of the array  

d) Copy of first element

 

Correct Answers of Core Java Interview Questions with Explanation

1. Answer: d

Explanation: Java is called ‘Platform Independent Language’ as it primarily works on the principle of ‘compile once, run everywhere’.

 

2. Answer: a) 

Explanation: Range of byte data in java is -128 to 127. But the byte data type in java is cyclic in nature.

 

3. Answer: c

Explanation: There are 8 types of primitive data types- int, char, boolean, byte, long, float, short, double.

 

4. Answer: b

Explanation: The size of float and double in java is 32 and 64.

 

5. Answer: b

Explanation: char[] ch = new char[5] is the correct syntax for declaring a character array.

 

6. Answer: b

Explanation: Automatic type conversion is possible in Int to long.

 

7. Answer: b

Explanation: 24 I will be printed.

 

8. Answer: c)

Explanation: This will give compile error - “Lossy conversion from int to short”

 

9. Answer: c)

Explanation: ++ is the increment operator. It adds 1 to the value of the variable.

 

10. Answer: a)

Explanation: When an array is passed to a method, a reference of the array is received by the method.

 

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 

Leave a comment

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