============================================================ Q-1: What will be the result of attempting to compile and run the following code? abstract class MineBase { abstract void amethod(); static int i; } public class Mine extends MineBase { public static void main(String argv[]){ int[] ar=new int[5]; for(i=0;i < ar.length;i++) System.out.println(ar[i]); } } ============================================================ Q-2: What will happen if you try to compile and run the following code public class MyClass { public static void main(String arguments[]) { amethod(arguments); } public void amethod(String[] arguments) { System.out.println(arguments); System.out.println(arguments[1]); } } ============================================================ Q-3: What gets displayed on the screen when the following program is compiled and run. Select the one correct answer. protected class example { public static void main(String args[]) { String test = "abc"; test = test + test; System.out.println(test); } } ============================================================ Q-4: What will happen if you attempt to compile and run the following code? class Base {} class Sub extends Base {} class Sub2 extends Base {} public class CEx{ public static void main(String argv[]){ Base b=new Base(); Sub s=(Sub) b; } } ============================================================ Q-5: What is the result? class Alpha { String getType() { return "alpha"; } } class Beta extends Alpha { String getType() { return "beta"; } } class Gamma extends Beta { String getType() { return "gamma"; } public static void main(String[] args) { Gamma g1 = new Alpha(); Gamma g2 = new Beta(); System.out.println(g1.getType() + " " + g2.getType()); } } ============================================================ Q-6: What is the result? class Feline { public String type = "f "; public Feline() { System.out.print("feline "); } } public class Cougar extends Feline { public Cougar() { System.out.print("cougar "); } public static void main(String[] args) { new Cougar().go(); } void go() { type = "c "; System.out.print(this.type + super.type); } } ============================================================ Q-7: What will happen when you attempt to compile and run the following code? public class Tux extends Thread{ static String sName = "vandeleur"; public static void main(String argv[]){ Tux t = new Tux(); t.piggy(sName); System.out.println(sName); } public void piggy(String sName){ sName = sName + " wiggy"; start(); } public void run(){ for(int i=0;i < 4; i++){ sName = sName + " " + i; } } } ============================================================ Q-8: What results from the following code? class MyClass { void myMethod(int i) {System.out.println("int version");} void myMethod(String s) {System.out.println("String version");} public static void main(String args[]) { MyClass obj = new MyClass(); char ch = 'c'; obj.myMethod(ch); } } ============================================================ Q-9: What is displayed when the following is executed? class Parent { private void method1() { System.out.println("Parent's method1()"); } public void method2() { System.out.println("Parent's method2()"); method1(); } } class Child extends Parent { public void method1() { System.out.println("Child's method1()"); } public static void main(String args[]) { Parent p = new Child(); p.method2(); } } ============================================================ Q-10: What will happen if you try to compile and run the following code? public class A { int add(int i, int j){ return i+j; } } public class B extends A{ public static void main(String argv[]){ short s = 9; System.out.println(add(s,6)); } } ============================================================ Q-11: What will happen if you try to compile and run the following code? public class A { int k; boolean istrue; static int p; public void printValue() { System.out.print(k); System.out.print(istrue); System.out.print(p); } } public class Test{ public static void main(String argv[]){ A a = new A(); a.printValue(); } } ============================================================ Q-12: What is the output from the following program? abstract class Writer { public static void write() { System.out.println("Writing..."); } } class Author extends Writer { public static void write() { System.out.println("Writing book"); } } public class Programmer extends Writer { public static void writ e() { System.out.println("Writing code"); } public static void main(String[] args) { Writer w = new Programmer(); w.write(); } }