Java Quiz 11 : Classes & Methods II By Tejas Chaudhari - September 2, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 11 : Classes & Methods II 1. What will be the output of the following Java program? class box { int width; int height; int length; int volume; void volume(int height, int length, int width) { volume = width*height*length; } } class Prameterized_method { public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(3,2,1); System.out.println(obj.volume); } } a) 0b) 1c) 6d) 25 2. What will be the output of the following Java program? class equality { int x; int y; boolean isequal() { return(x == y); } } class Output { public static void main(String args[]) { equality obj = new equality(); obj.x = 5; obj.y = 5; System.out.println(obj.isequal()); } } a) falseb) truec) 0d) 1 3. What will be the output of the following Java program? class box { int width; int height; int length; int volume; void volume() { volume = width*height*length; } } class Output { public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(); System.out.println(obj.volume); } } a) 0b) 1c) 25d) 26 4. In the following Java code, which call to sum() method is appropriate? class Output { public static int sum(int ...x) { return; } static void main(String args[]) { sum(10); sum(10,20); sum(10,20,30); sum(10,20,30,40); } } a) only sum(10)b) only sum(10,20)c) only sum(10) & sum(10,20)d) all of the mentioned 5. What will be the output of the following Java program? class area { int width; int length; int volume; area() { width=5; length=6; } void volume() { volume = width*length*height; } } class cons_method { public static void main(String args[]) { area obj = new area(); obj.volume(); System.out.println(obj.volume); } } a) 0b) 1c) 30d) error 6. What is the return type of Constructors?a) intb) floatc) voidd) none of the mentioned 7. Which keyword is used by the method to refer to the object that invoked it?a) importb) catchc) abstractd) this 8. Which of the following is a method having same name as that of its class?a) finalizeb) deletec) classd) constructor 9. Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?a) deleteb) freec) newd) none of the mentioned 10. Which function is used to perform some action when the object is to be destroyed?a) finalize()b) delete()c) main()d) none of the mentioned 11. What will be the output of the following Java code? class box { int width; int height; int length; int volume; box() { width = 5; height = 5; length = 6; } void volume() { volume = width*height*length; } } class constructor_output { public static void main(String args[]) { box obj = new box(); obj.volume(); System.out.println(obj.volume); } } a) 100b) 150c) 200d) 250 12. What will be the output of the following Java code? class San { San()throws IOException { } } class Foundry extends San { Foundry() { } public static void main(String[]args) { } } a) compile time errorb) run time errorc) compile and runs fined) unreported exception java.io.IOException in default constructor 13. What will be the output of the following Java code? class box { int width; int height; int length; int volume; void finalize() { volume = width*height*length; System.out.println(volume); } protected void volume() { volume = width*height*length; System.out.println(volume); } } class Output { public static void main(String args[]) { box obj = new box(); obj.width=5; obj.height=5; obj.length=6; obj.volume(); } } a) 150b) 200c) Run time errord) Compilation error 14. Which of the following statements are incorrect?a) default constructor is called at the time of object declarationb) constructor can be parameterizedc) finalize() method is called when a object goes out of scope and is no longer neededd) finalize() method must be declared protected 15. What will be the output of the following Java code? class area { int width; int length; int area; void area(int width, int length) { this.width = width; this.length = length; } } class Output { public static void main(String args[]) { area obj = new area(); obj.area(5 , 6); System.out.println(obj.length + " " + obj.width); } } a) 0 0b) 5 6c) 6 5d) 5 5 Time is Up!