Java is a high level, class based, object oriented, secured and general purpose programming language. It is a great choice for the developers for creating games, web and mobile applications. The features like multithreading and platform independent compilation makes it stand out from other programming languages.
Question 1: Who is responsible for converting a java program to java bytecode?
A) JVM
B) Java Compiler
C) JIT
D) None of these
Answer: B) Java Compiler
Explanation: Java Virtual Machine is responsible for converting bytecode to executable java code.
Question 2: Who is responsible for converting bytecode to machine-specific executable code.
A) JDK
B) JVM
C) Java Compiler
D) None of these
Answer: B) JVM
Explanation: Java Development Kit enables us to create
Question 3: Which of the following is true about ArrayList?
A) It is resizable
B) It can be found in java.util package
C) It has get() and add() methods
D) All of these
Answer: All of these
Explanation: ArrayList is a resizable array which can be used after importing the java.util package.
Question 4: Which of the following is true about Lambda Expressions?
A) Lambda expressions must need a name
B) It cannot have 0 parameters
C) Both of these
D) None of these
Answer: D) None of these
Explanation: Lambda expressions are close to methods, they can take parameters and return a value.
Question 5: For Method Overloading, methods can have:
A) Same method name
B) Different number of parameters
C) Different type of parameters
D) All of the above
Answer: D) All of the above
Explanation: Method overloading means functions having the same name but having different numbers of types of parameters.
Question 6: Which keyword is used to declare a variable as constant in java?
A) const
B) final
C) Both of these
D) None of these
Answer: B) final
Explanation: final keyword is used to declare any
Question 7: Which signatures of methods are mandatory?
A) Method Name
B) Return Type
C) Access Specifier
D) Both A and B
E) All of these
Answer: D) Both A and B
Explanation: A method can have 5 signatures:
Method Name: it is mandatory, we would need it to call the function.
Question 8: Which of the following are the properties of constructor in java?
A) They cannot have the same name as the class name.
B) They have a return type
C) They are called automatically when an object is created
D) All of these
Answer: C) They are called automatically when an object is created
Explanation: Constructors are the methods inside the class which have the same name as the class and have no return type. They are called automatically when an object of the class is created. They are used to initialize the objects.
Question 9: Which of the following is not a way to create objects in java?
A) New keyword
B) Clone method
C) Both of these
D) None of these
Answer: C) Both of these
Explanation: new keyword is the most basic way to create objects of the class
Question 10: In Static Classes:
A) All variables and methods of class are static
B) Constructor is private
C) Can only be accessed using class name
D) All of the above
Answer: D) All of the above
Explanation: All the variables inside the static classes are static, it has a private constructor so now the only way to access it is using the class name.