Java Quiz 10 : Classes and Methods I By Tejas Chaudhari - September 1, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 10 : Classes and Methods I 1. What is the stored in the object obj in following lines of Java code? box obj;a) Memory address of allocated memory of objectb) NULLc) Any arbitrary pointerd) Garbage 2. Which of these keywords is used to make a class?a) classb) structc) intd) none of the mentioned 3. Which of the following is a valid declaration of an object of class Box?a) Box obj = new Box();b) Box obj = new Box;c) obj = new Box();d) new Box obj; 4. Which of these operators is used to allocate memory for an object?a) mallocb) allocc) newd) give 5. Which of these statement is incorrect?a) Every class must contain a main() methodb) Applets do not require a main() method at allcc) There can be only one main() method in a programcd) main() method must be made public 6. What will be the output of the following Java program? class main_class { public static void main(String args[]) { int x = 9; if (x == 9) { int x = 8; System.out.println(x); } } } a) 9b) 8c) Compilation errord) Runtime error 7. Which of the following statements is correct?a) Public method is accessible to all other classes in the hierarchyb) Public method is accessible only to subclasses of its parent classc) Public method can only be called by object of its classd) Public method can be accessed by calling object of the public class 8. What will be the output of the following Java program? class box { int width; int height; int length; } class mainclass { public static void main(String args[]) { box obj = new box(); obj.width = 10; obj.height = 2; obj.length = 10; int y = obj.width * obj.height * obj.length; System.out.print(y); } } a) 12b) 200c) 400d) 100 9. What will be the output of the following Java program? class box { int width; int height; int length; } class mainclass { public static void main(String args[]) { box obj1 = new box(); box obj2 = new box(); obj1.height = 1; obj1.length = 2; obj1.width = 1; obj2 = obj1; System.out.println(obj2.height); } } a) 1b) 2c) Runtime errord) Garbage value 10. What will be the output of the following Java program? class box { int width; int height; int length; } class mainclass { public static void main(String args[]) { box obj = new box(); System.out.println(obj); } } a) 0b) 1c) Runtime errord) [email protected] in hexadecimal formc 11. What is the return type of a method that does not return any value?a) intb) floatc) voidd) double 12. What is the process of defining more than one method in a class differentiated by method signature?a) Function overridingb) Function overloadingc) Function doublingd) None of the mentioned 13. Which of the following is a method having same name as that of it’s class?a) finalizeb) deletec) classd) constructor 14. Which method can be defined only once in a program?a) main methodb) finalize methodc) static methodd) private method 15. Which of this statement is incorrect?a) All object of a class are allotted memory for the all the variables defined in the classb) If a function is defined public it can be accessed by object of other class by inheritationc) main() method must be made publicd) All object of a class are allotted memory for the methods defined in the class Time is Up!