Sail E0 Webinar

MCQs

Total Questions : 26 | Page 3 of 3 pages
Question 21. What will be the output for the below code ?1. public class Test{2. int i=8;3. int j=9;4. public static void main(String[] args){5. add();6. }7. public static void add(){8. int k = i+j;9. System.out.println(k);10. }11. }
  1.    Compilation fails with an error at line 5
  2.    Compilation fails with an error at line 8
  3.    0
  4.    None of these
  5.    17
 Discuss Question
Answer: Option B. -> Compilation fails with an error at line 8
Question 22. What is the output for the below code ?1. public class Test{2. public static void main(String[] args){3. byte b = 6;4. b+=8;5. System.out.println(b);6. b = b+7;7. System.out.println(b);8. }9. }
  1.    Compilation fails with an error at line 4
  2.    14 13
  3.    None of these
  4.    14 21
  5.    Compilation fails with an error at line 6
 Discuss Question
Answer: Option E. -> Compilation fails with an error at line 6
Question 23. What will be the output for the below code ?1. public class Test{2. public static void main(String[] args){3. byte i = 128;4. System.out.println(i);5. }6. }
  1.    None of these
  2.    Compilation fails with an error at line 4
  3.    0
  4.    128
  5.    Compilation fails with an error at line 3
 Discuss Question
Answer: Option E. -> Compilation fails with an error at line 3
Question 24. What is the output for the below code ?1. public class Test{2. public static void main(String[] args){3. int i = 010;4. int j = 07;5. System.out.println(i);6. System.out.println(j);7. }8. }
  1.    Compilation fails with an error at line 3
  2.    None of these
  3.    Compilation fails with an error at line 5
  4.    10 7
  5.    8 7
 Discuss Question
Answer: Option E. -> 8 7
Question 25. What will be output of following program?public class Test{ public static void main(String[] args){ byte b=127; b++; b++; System.out.println(b); }}
  1.    2
  2.    -127
  3.    None of these
  4.    129
  5.    Compiler error
 Discuss Question
Answer: Option B. -> -127
Question 26. Determine output:public class Test{ int a = 10; public void method(int a){ a += 1; System.out.println(++a); } public static void main(String args[]){ Test t = new Test(); t.method(3); }}
  1.    11
  2.    5
  3.    None of these
  4.    12
  5.    4
 Discuss Question
Answer: Option B. -> 5

Latest Videos

Latest Test Papers