25-November 2022
Training

Core Java Interview Questions

..
Core Java Interview Questions

1. What to use for both the conditions to be true

a. ||                                                      c. !

b. &&                                                 d. $

2. What to use for one of the conditions to be true

a. ||                                                    c. !

b. &&                                                 d. $

3. Appropriate data type for the value 6.3

a. Integer                         c. char

b. Boolean                       d. double

4. Which environment variable is used to set the java path?

a) MAVEN_Path                               c) JAVA

b) JavaPATH                       d) JAVA_HOME

5. What will be the output of the following Java code?

class Test {

        public static void main(String args[])

        {       

             int a = 3;

             System.out.print(++a * 8);

        }

    }

a) 32                                                      c) 24

b) 33                                                      d) 25

6. What is the extension of java code files?

a) .js                                      c) .class

b) .txt                                    d) .java

7. Which of these cannot be used for a variable name in Java?

a) identifier & keyword                                 c) keyword

b) identifier                                                        d) none of the mentioned

8. Who invented Java programming?

a) Guido van Rossum                  c) Dennis Ritchie

b) Bjarne Stroustrup                    d) James Gosling

9. Which one of the following is not a Java feature?

a) Object-oriented                          c) Portable

b) Use of pointers                           d) Dynamic and Extensible

10. Which component is used to compile, debug and execute the java programs?

a) JRE                                                    c) JDK

b) JIT                                                     d) JVM

 

 

-------------------------------------------------------------------------------------------------------------

 

Correct Answers with Explanation

  1. Correct Answer: b) &&

           Explanation: && is used for both the conditions to be true where || is used for one of the conditions to be true. && is called AND operator whereas || is called OR operator.

        2. Correct Answer: a) ||

            Explanation: && is used for both the conditions to be true where || is used for one of the conditions to be true. && is called AND operator whereas || is called OR operator.

        3. Correct Answer: d) double

            Explanation: double is the data type for the value 6.3

         4. Answer: d

            Explanation: JAVA_HOME is used to store a path to the java installation.

         5. Answer: a

            Explanation: Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.

            $ javac Test.java

            $ java Test

            32

         6. Answer: d

            Explanation: Java files have .java extension.

           7. Answer: c

           Explanation: Keywords are specially reserved words that can not be used for naming a user-defined variable, for example: class, int, for, etc.

           8. Answer: d

           Explanation: Java programming was developed by James Gosling at Sun Microsystems in 1995. James Gosling is well known as the father of Java.

            9. Answer: b

             Explanation: Pointers is not a Java feature. Java provides an efficient abstraction layer for developing without using a pointer in Java. Features of Java Programming are Portable, Architectural Neutral, Object-Oriented,                 Robust, Secure, Dynamic and Extensible, etc.

            10. Answer: c

            Explanation: JDK is a core component of Java Environment and provides all the tools, executable and binaries required to compile, debug and execute a Java Program.

Leave a comment

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