java exam 0 votes, 0 avg 371 123456789101112131415 Java Questions 1 / 15 1. Find the output of the following code. Public class Solution{ Public static void main(String args[]){ Int i; for(i = 1; i < 6; i++){ if(i > 3) continue; } System.out.println(i); } } A. 3 B. 4 C. 5 D. 6 2 / 15 2. Find the output of the following program. public class Solution{ public static void main(String[] args){ int[] x = {120, 200, 016}; for(int i = 0; i < x.length; i++){ System.out.print(x[i] + “ “); } } } A. 120 200 016 B. 120 200 14 C. 120 200 16 D. none of the above 3 / 15 3. From the following statements which is a disadvantage of an java array? A. An array can hold primitive types data B. An array has its size that is known as array length C. An array knows only its type that it contains. Array type is checked at the compile-time D. An array holds only one type of data 4 / 15 4. Which data type value is returned by all transcendental math functions? A. int B. float C. double D. long 5 / 15 5. Which of these keywords are used for the block to be examined for exceptions? A. check B. throw C. catch D. try 6 / 15 6. Find the output of the following code. class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Quiz"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } } A. QuizziuQ B. ziuQQuiz C. Quiz D. ziuQ 7 / 15 7. Which mechanism is used when a thread is paused running in its critical section and another thread is allowed to enter (or lock) in the same critical section to be executed? A. Inter-thread communication B. Initial-thread communication C. Mutual Exclusive D. none of the above 8 / 15 8. Which of these can be used to differentiate two or more methods having the same name? A. Parameters data type B. Number of parameters C. Return type of method D. All of the mentioned 9 / 15 9. Which of the following is true about public access modifier? A. Variables, methods and constructors which are declared public can be accessed by any class B. Variables, methods and constructors which are declared public can be accessed by any class lying in same pacckage. C. Variables, methods and constructors which are declared public in the superclass can be accessed only by it’s child class. D. none of the above 10 / 15 10. Find the output of the following code. class box { int width; int height; int length; } class main { 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. 100 B. 400 C. 200 D. 12 11 / 15 11. What will be the output of the following Java program? class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } } A. 1 B. 2 C. 3 D. 4 12 / 15 12. 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 13 / 15 13. In Iterator, hasMoreElements() method of Enumeration has been changed to: A. hasNextElement() B. isNext() C. hasNext() D. name remains same 14 / 15 14. What is the process of defining two or more methods within same class that have same name but different parameters declaration? A. method overloading B. method overriding C. method hiding D. none of the mentioned 15 / 15 15. How to sort an array? A. Array.sort() B. Arrays.sort() C. Collection.sort() D. System.sort() Your score isThe average score is 36% LinkedIn Facebook VKontakte 0% Restart quiz By Wordpress Quiz plugin