java exam 0 votes, 0 avg 363 123456789101112131415 Java Questions 1 / 15 1. What will be the output of the following Java code? class Char { public static void main(String args[]) { char ch1, ch2; ch1 = 88; // code for X ch2 = 'Y'; System.out.print("ch1 and ch2: "); System.out.println(ch1 + " " + ch2); } } A. ch1 and ch2: X Y B. ch1 and ch2: x y C. ch1 and ch2: 1 3 D. None of the above 2 / 15 2. 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 3 / 15 3. How is Date stored in database? A. java.sql.Date B. java.util.Date C. java.sql.DateTime D. java.util.DateTime 4 / 15 4. 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 5 / 15 5. Which of the following are not java modifiers? A. public B. private C. friendly D. transient 6 / 15 6. 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 7 / 15 7. Find the output of the following code. import java.util.*; class Collection_iterators { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); Collections.sort(list); while(i.hasNext()) System.out.print(i.next() + " "); } } A. 1 2 5 8 B. 2 1 8 5 C. 1 5 8 2 D. 2 8 5 1 8 / 15 8. What is the default value of String variable? A. “” B. '’ C. null D. not defined 9 / 15 9. 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 10 / 15 10. 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 11 / 15 11. What will be the output of the following Java program? class recursion { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { public static void main(String args[]) { recursion obj = new recursion() ; System.out.print(obj.fact(5)); } } A. 24 B. 30 C. 120 D. 720 12 / 15 12. Find the output of the following code. class leftshift_operator { public static void main(String args[]) { byte x = 64; int i; byte y; i = x << 2; y = (byte) (x << 2); System.out.print(i + " " + y); } } A. 0 256 B. 0 64 C. 256 0 D. 64 0 13 / 15 13. Which of these data types is used to store command line arguments? A. Array B. Stack C. String D. Integer 14 / 15 14. What will be the output of the following Java code? class static_out { static int x; static int y; void add(int a, int b) { x = a + b; y = x + b; } } public class static_use { public static void main(String args[]) { static_out obj1 = new static_out(); static_out obj2 = new static_out(); int a = 2; obj1.add(a, a + 1); obj2.add(5, a); System.out.println(obj1.x + " " + obj2.y); } } A. 7 7.4 B. 6 6.4 C. 7 9 D. 9 7 15 / 15 15. Which of these is correct about passing an argument by call-by-value process? A. Copy of argument is made into the formal parameter of the subroutine and changes made on parameters of subroutine have effect on original argument B. Copy of argument is made into the formal parameter of the subroutine C. Reference to original argument is passed to formal parameter of the subroutine D. Reference to original argument is passed to formal parameter of the subroutine and changes made on parameters of subroutine have effect on original argument Your score isThe average score is 36% LinkedIn Facebook VKontakte 0% Restart quiz By Wordpress Quiz plugin