Java Quiz October 6, 2024 | No Comments 0 votes, 0 avg 167 123456789101112131415 Java Questions 1 / 15 1. Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B? A. super(void); B. Superclass.(); C. super.A(); D. super(); 2 / 15 2. What will be the output of the following Java program? class recursion { int func (int n) { int result; result = func (n - 1); return result; } } class Output { public static void main(String args[]) { recursion obj = new recursion() ; System.out.print(obj.func(12)); } } A. O B. 1 C. Compilation error D. run time error 3 / 15 3. Find the output of the following code. class bool_operator { public static void main(String args[]) { boolean a = true; boolean b = !true; boolean c = a | b; boolean d = a & b; boolean e = d ? b : c; System.out.println(d + " " + e); } } A. true false B. false false C. true true D. false true 4 / 15 4. Which of these is returned by “greater than”, “less than” and “equal to” operators? A. Integers B. Floating – point numbers C. Boolean D. None of the mentioned 5 / 15 5. What is the function of javap command? A. This command is used to run java compiler B. A command to run a non-optimized version of the java compiler C. A command to create HTML document in API style D. A command to seperate java class files 6 / 15 6. A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction? A. Declare the method with the keyword protected B. Declare the method with the keyword private C. Do not declare the method with any accessibility modifiers D. Declare the method with the keyword public and private. 7 / 15 7. What will be the output of the following Java code? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o')); } } A. 6 4 6 9 B. 5 4 5 9 C. 7 8 8 9 D. 4 3 6 9 8 / 15 8. How to format date from one form to another? A. SimpleDateFormat B. DateFormat C. SimpleFormat D. DateConverter 9 / 15 9. What will be the output of the following Java program? class Output { public static void main(String args[]) { double x = 2.0; double y = 3.0; double z = Math.pow( x, y ); System.out.print(z); } } A. 9.O B. 8.O C. 4.O D. 2.O 10 / 15 10. Which of these is an incorrect array declaration? A. int arr[] = new int[5] B. int [] arr = new int[5] C. int arr[] = new int[5] D. int arr[] = int [5] new 11 / 15 11. Which of these statements are incorrect? A. The left shift operator, <<, shifts all of the bits in a value to the left specified number of times B. The right shift operator, >>, shifts all of the bits in a value to the right specified number of times C. The left shift operator can be used as an alternative to multiplying by 2 D. The right shift operator automatically fills the higher order bits with 0 12 / 15 12. Which of these is necessary condition for automatic type conversion in Java? A. The destination type is smaller than source type B. The destination type is larger than source type C. The destination type can be larger or smaller than source type D. None of the mentioned 13 / 15 13. Which of these method of Object class can clone an object? A. Objectcopy() B. copy() C. Object clone() D. clone() 14 / 15 14. Which of these keywords cannot be used for a class which has been declared final? A. abstract B. extends C. abstract and extends D. none of the mentioned 15 / 15 15. What is Recursion in Java? A. Recursion is a class B. Recursion is a process of defining a method that calls other methods repeatedly C. Recursion is a process of defining a method that calls itself repeatedly D. Recursion is a process of defining a method that calls other methods which in turn call again this method Your score is The average score is 35% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Quiz