1. What is the use of the "this" keyword in Java?
- Referring to the instance variable when a local variable has the same name
- Passing itself to the method of the same class
- Passing itself to another method
- Calling another constructor in constructor chaining
Answer: a
Description: "this" is an important keyword in java. It helps to distinguish between local variable and variables passed in the method as parameters.
- Web Applications
- Standalone Applications
- Mobile Applications
- Distributed Applications
Answer: b
Description: Standalone applications use GUI components such as AWT, Swing, and JavaFX for desktop environments.
3. What is the primary role of the javac command in Java?
- To execute Java applications
- To compile Java source code into bytecode
- To manage Java packages
- To optimize Java code
Answer: b
Description: The javac command is used to compile Java source code into bytecode.
4. What is the purpose of the final keyword in Java?
- To create a constant variable
- To prevent method overriding
- To prevent inheritance
- All of the above
Answer: d
Description: The final keyword can be used to create constants, prevent method overriding, and prevent class inheritance.
5) When an array is passed to a method, what does the method receive?
- The reference of the array
- A copy of the array
- Length of the array
- Copy of the first element
Answer: a
Description: When an array is passed to a method, the method receives a reference to the original array, allowing it to modify the array's elements directly.