Java Quiz October 6, 2024 | No Comments 0 votes, 0 avg 363 123456789101112131415 Java Questions 1 / 15 1. Which of the following is not an OOPS concept in Java? A. Polymorphism B. Inheritance C. Compilation D. Encapsulation 2 / 15 2. 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 3 / 15 3. Find the output of the following code. class ternary_operator { public static void main(String args[]) { int x = 3; int y = ~ x; int z; z = x > y ? x : y; System.out.print(z); } } A. 1 B. 3 C. -4 D. o 4 / 15 4. What is the syntax for java main method? A. public void main(String[] args) B. public static void main() C. public static void main(String[] args) D. none of the above 5 / 15 5. Which environment variable is used to set the java path? A. MAVEN_Path B. JavaPATH C. JAVA D. JAVA_HOME 6 / 15 6. What is an assignment statement? A. Assigning a value to a variable B. Adding a number to an int C. Assigning a multiplication D. Assigning a name to a variable 7 / 15 7. Which constructor creates an empty string buffer with the specified capacity as length. A. StringBuffer() B. StringBuffer(String str) C. StringBuffer(int capacity) D. none of the above 8 / 15 8. Find the value of A[1] after execution of the following program. int[] A = {0,2,4,1,3}; for(int i = 0; i < a.length; i++){ a[i] = a[(a[i] + 3) % a.length]; } A. 1 B. 2 C. 3 D. o 9 / 15 9. Which of these statements is incorrect about Thread? A. start() method is used to begin execution of the thread B. run() method is used to begin execution of a thread before start() method in special cases C. A thread can be formed by implementing Runnable interface only D. A thread can be formed by a class that extends Thread class 10 / 15 10. The following program is an example for? class Student{ int id; String name; void display(){System.out.println(id+" "+name);} public static void main(String args[]){ Student s1=new Student(); Student s2=new Student(); s1.display(); s2.display(); } } A. Parameterized constructor B. Default Constructor C. Overloading Constructor D. None of the above 11 / 15 11. Find the output of the following program. class output { public static void main(String args[]) { double a, b,c; a = 3.0/0; b = 0/4.0; c=0/0.0; System.out.println(a); System.out.println(b); System.out.println(c); } } A. Infinity B. NaN C. all of the above D. o.o 12 / 15 12. What will be the output of the following Java program? class recursion { int func (int n) { int result; if (n == 1) return 1; result = func (n - 1); return result; } } class Output { public static void main(String args[]) { recursion obj = new recursion() ; System.out.print(obj.func(5)); } } A. 1 B. 120 C. O D. None of the mentioned 13 / 15 13. Choose the appropriate data type for this field: isSwimmer A. double B. boolean C. string D. int 14 / 15 14. Which of these keywords is used to prevent content of a variable from being modified? A. final B. last C. constant D. static 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 isThe average score is 36% LinkedIn Facebook VKontakte 0% Restart quiz By Wordpress Quiz plugin Quiz