About  | Contact  | Site Map  |  Mirror    |
Voodoo Exam  |  Question Bank  |  Databases  |  Tutorials    |
|
    |
Question Bank 1 We have moved to a new website(www.irixtech.com) where you can now take mock exams online, come back & review your answers later, ask questions in our forums & SCJP questions ranging from SCJP 1.4 to SCJP 6.0, including these question banks & dumps from this site. Click here to be taken to our new website. Comments & suggestions will be highly appreciated . If you'd like to see your question's here mail me . 1. Consider the following code , what is the output provided a valid file name is given on the command prompt? import java.io.*; class Q032{ public static void main(String args[]) throws Exception{ FileInputStream fin; int c = 0; try { fin = new FileInputStream(args[0]); while ((c = fin.read()) != -1) { System.out.print((char)c); } } catch (Exception e) { System.out.println(e); } fin.close(); } }; Options :
2. What is the output for the following - class A{ static int i; A(){ ++i; } private int get(){ return ++i; } }; class B extends A{ B(){ i++; } int get(){ return ( i + 3); } }; class Q028 extends B{ public static void main(String ka[]){ Q028 obj = new Q028(); A ob_a = new A(); ob_a = (A)obj; System.out.println(ob_a.get()); } }; Options :
3. What is the output ? class Q006{ public static void main(String args[]){ boolean flag = false; if ( flag = true) { System.out.println("true"); } if ( flag == false) { System.out.println("false"); } } }; Options :
4. What is the output ? class A{ A(){ System.out.print("1"); } }; class Q005 extends A{ Q005(){ System.out.print("2"); } public static void main(String args[]){ Q005 obj = new Q005(); System.out.println("3"); } }; Options :
5. What is the output ? class Q002{ public static void main(String args[]){ int i = -1; System.out.println(-1 >> 17); } }; Options :
6. Predict the output - class Q008{ public static void main(String args[]){ int i = -1; System.out.println((i<0)?-i:i); } }; Options :
7. Will the following compile ? If yes what is the output ? class Q009{ public static void main(String args[]){ System.out.println((Math.abs(Integer.MIN_VALUE))); //FYI Integer.MIN_VALUE = -2147483648 } }; Options :
8. Will the following code compile ? If yes , what is the output ? class Q012{ Q012(int i){ System.out.println(i); this.i = i; } public static void main(String ka[]){ Q012 obj = new Q012(10); } } Options :
9. What is the output of this code ? class Q011{ int i; Q011(int i){ System.out.println(i); this.i = i; } public static void main(String ka[]){ Q011 obj = new Q011(10); System.out.println(obj.i); } } Options :
10. What is the output for this piece ? class Test{ static boolean flag; public static void main(String args[]){ if ( flag ) { System.out.println(flag); } } }; Options :
Answers :
|
© 2000-2002 Ashish Hareet |