1. What does the public keyword indicate in a Java class?
Explanation: The public keyword in Java indicates that the class is accessible from any package.
Report for correction2. What is the default value of an uninitialized int variable in Java?
Explanation: Uninitialized int variables in Java have a default value of 0.
Report for correction3. What is the Java keyword for defining a subclass of a class?
Explanation: The extends keyword is used to define a subclass of a class in Java.
Report for correction4. What is the Java package that contains classes for input and output operations?
Explanation: The java.io package in Java contains classes for input and output operations, such as reading and writing files.
Report for correction5. What is the maximum value that can be stored in an int variable in Java?
Explanation: The maximum value that can be stored in an int variable in Java is 2,147,483,647.
Report for correction6. What is the purpose of the char data type in Java?
Explanation: The char data type in Java is used to store single characters, such as letters and symbols.
Report for correction7. What is the purpose of the super keyword in Java?
Explanation: The super keyword in Java is used to call a method or access a member from the superclass.
Report for correction8. What is the purpose of the this keyword in Java?
Explanation: The this keyword in Java is used to refer to the current instance of the class.
Report for correction9. What is the result of "Hello" + "World" in Java?
Explanation: In Java, the + operator is used for concatenating strings.
Report for correction10. What is the result of 5 % 2 in Java?
Explanation: The % operator in Java calculates the remainder, so 5 % 2 results in 1.
Report for correction11. What is the result of the expression 10 / 3 in Java?
Explanation: In Java, integer division truncates the decimal part, so 10 / 3 results in 3.
Report for correction12. What is the result of the expression 5 / 0 in Java?
Explanation: Attempting to divide by zero in Java results in an error or exception.
Report for correction13. What is the result of the expression true && false in Java?
Explanation: The && operator in Java represents the logical AND operation, and the result is false if any of the operands is false.
Report for correction14. What is the role of the final keyword in Java?
Explanation: The final keyword in Java is used to define variables, methods, or classes that cannot be modified or extended.
Report for correction15. What is the role of the static keyword in Java?
Explanation: The static keyword in Java is used to define methods or variables that are associated with the class rather than with instances of the class.
Report for correction16. Which data type is used to store single-precision floating-point numbers in Java?
Explanation: The float data type is used to store single-precision floating-point numbers in Java.
Report for correction17. Which Java access modifier allows a member to be accessed only within its own class?
Explanation: The private access modifier restricts access to members only within the same class.
Report for correction18. Which Java data type is used to store true/false values?
Explanation: The boolean data type in Java is used to store true/false values.
Report for correction19. Which Java keyword is used for method overriding?
Explanation: The @Override annotation is used in Java to indicate that a method is intended to override a method from its superclass.
Report for correction20. Which Java loop is used when you want to execute a block of code at least once?
Explanation: The do-while loop in Java is used when you want to execute a block of code at least once, as the condition is checked after the loop body.
Report for correction21. Which Java statement is used to exit a loop prematurely?
Explanation: The break statement is used to exit a loop prematurely in Java.
Report for correction22. Which of the following is a valid variable name in Java?
Explanation: Variable names in Java cannot start with a digit, so _myVariable is a valid variable name.
Report for correction23. Which of the following is a valid way to declare a constant in Java?
Explanation: In Java, constants are declared using the final keyword before the data type.
Report for correction24. Which of the following is a valid way to declare an array in Java?
Explanation: In Java, you declare an array using the new keyword and specify the size in square brackets.
Report for correction int[5] numbers = {1, 2, 3, 4, 5};
int[] numbers = new int[5];
int numbers = [1, 2, 3, 4, 5];
int numbers[5] = {1, 2, 3, 4, 5};
25. Which of the following is not a valid Java data type?
Explanation: char@ is not a valid Java data type. The correct data type is char.
Report for correction