Top 15 Java Interview Questions - Collegeintegral



These are some of the intriguing and thought-provoking questions we have decided to compile for the learners who wish to get an idea and edge over the sort of questions asked and for teachers who wish to ask insight based questions in an interview

 

1. Which of the following is not a java program?





ANSWER= (D) None of these
Explanation:- JVM and JRE are part of JDK and JDK stands for java development kit, it is a development kit that is used to develop software, embedded programs, and programs in general for android and desktop using java



 

2.  Is Java not purely an object-oriented language? if yes, which of the following does it fall short on?




ANSWER= (C) All pre-defined types are objects Explanation:- java is not a pure object-oriented programming language because it falls short in the case of pre-defined data types, in java predefined types are classified as non-objects(primitive data types).


 

3. An expression contains all the primitive data types except Boolean, which data type will the expression implicitly get type casted to?





ANSWER= (D) double
Explanation:- implicit typecasting works by converting a lower data type to a higher data type. byte, short, int, long, float, double (from left to right).


 

4. Why is the final keyword used in java?





ANSWER= (D) All of the above
Explanation:- final keyword is used to do the a, b, and c options as adding the final keyword before a method ensures it can't be overridden, and making a variable final ensures it is a constant.


 

5. An object calls a function inside a derived class that has the same name as the base class, which function is called?





ANSWER= (B) derived class function
Explanation:- Runtime polymorphism occurs and results in the function inside the base class getting overridden.


 

6. Which of these is a java program that does compilation, debugging & execution?





ANSWER= (C) JDK
Explanation:- JDK is the java development kit, it is the program that does all these tasks, and the other options are part of JDK and do specific tasks.


 

7. An object calls a static function inside a derived class that has the same name as the base class, which function is called?

    derived class function
    can't comment due to a lack of information
ANSWER= (A) base class function
Explanation:- Runtime polymorphism cant occur as the function in consideration are static and results in the function inside the base class getting called.


 

8. which of the following is true about arrays in java?





ANSWER= (D) Option A & C
Explanation:- Arrays are objects in java, their length function is a final function thus the value can not be changed after they are created and their storage allocation is done on the heap as is the case for objects.


 

9. Which of the following is a logical operator?





ANSWER= (D) All of these
Explanation:- All of these are logical operators in java "&&" is used for "and" & "||" is used for "or"


 

10. Which keyword will be used to store a 32-bit integer value?





ANSWER= (B) int
Explanation:- int is the best choice here as short cant handle a 32-bit size and long is too large and it will be a waste of memory to store a 32-bit number in long


 

11. which of the following is not an object-oriented programming language?





ANSWER= (A) C
Explanation:- C++, Java, and Python are object-oriented programming languages and C is a procedural programming language.


 

12. Any statement that is declarative in java must end with which of the following?





ANSWER= (D) ;
Explanation:- It is part of the syntax in java to use a semicolon at the end of statements (;)


 

13. which of the following is not a java keyword?





ANSWER= (A) study
Explanation:- static is a keyword in java and so are public and private(access modifiers)


 

14. what will happen if a final function inside the base class is overridden inside the derived class?




ANSWER= (C) Compile time error
Explanation:- compile-time error will occur as a final function cannot be overridden 


 

15. Which of the following is a superclass of all the errors and exceptions in java?





ANSWER= (D) Throwable
Explanation:- All the errors and exceptions in Java are subclasses of the in-built class throwable

 

Post a Comment

Previous Post Next Post