Find the output of this program. main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
-1
1
0
Compiler error
Find the output of this program. main() { int i=5; printf(“%d”,i=++i ==6); }
6
5
Question 3 Given: 11. public class Test { 12. public static void main(String [] args) { 13. int x =5; 14. boolean b1 = true; 15. boolean b2 = false; 16. 17.if((x==4) && !b2) 18. System.out.print(”l “); 19. System.out.print(”2 “); 20. if ((b2 = true) && b1) 21. System.out.print(”3 “); 22. } 23. } What is the result?
D. 2 3
A. 2 B. 3
C. 1 2 E. 1 2 3
F. Compilation fails. G. Au exceptional is thrown at runtime.
A. final
C. native
F. abstract
G. protected
Question 5 Given: 10. interface Foo {} 11. class Alpha implements Foo { } 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?
B. Foo f= (Delta)x;
A. Alpha a = x;
D. The code on line 31 throws an exception.
C. Foo f= (Alpha)x; D. Beta b = (Beta)(Alpha)x;
Question 5Given:10. interface Foo {}11. class Alpha implements Foo { }12. class Beta extends Alpha {}13. class Delta extends Beta {14. public static void main( String[] args) {15. Beta x = new Beta();16. // insert code here17. }18. }Which code, inserted at line 16, will cause ajava.lang.ClassCastException?
Find the output of this program. main() { int a[10]; printf("%d",*a+1-*a+3) ; }
3
-2
4