1. Question: What would happen on trying to compile and run the following code?
    class House {
     
     public final void MaintainMethod() {
      System.out.println("MaintainMethod");
     }
    }
    
    public class Building extends House {
     
     public static void main(String argv[]) {
      House h = new House();
      h.MaintainMethod();
     }
    }

    A
    A runtime error will occur because class House is not defined as final.

    B
    Successful compilation and output of "MaintainMethod" at run time.

    C
    A compilation error indicating that a class with any final methods must be declared final itself.

    D
    A compilation error indicating that you cannot inherit from a class with final methods.

    Note: Not available
    1. Report
  2. Question: Which of the following code snippets will generate five random numbers between 0 and 200?

    A
    Random r = new Random(); 
    for (int i = 0; i < 5; i++) {
     System.out.println(r.nextInt(0,200)); 
    }

    B
    Random r = new Random(200); 
    for (int i = 0; i < 5; i++) { 
     System.out.println(r.nextInt()); 
    }

    C
    Random r = new Random(); 
    for (int i = 0; i < 5; i++) { 
     System.out.println(r.nextInt(200)); 
    }

    D
    Random r = new Random(200); 
    for (int i = 0; i < 5; i++) { 
    System.out.println(r.nextInt(0)); 
    }

    Note: Not available
    1. Report
  3. Question: What will be the output when this code is compiled and run?
    public class Test {
    
     public Test() {
    
      Bar b = new Bar();
      Bar b1 = new Bar();
      update(b);
      update(b1);
      b1 = b;
      update(b);
      update(b1);
     }
    
     private void update(Bar bar) {
    
      bar.x = 20;
      System.out.println(bar.x);
     }
    
     public static void main(String args[]) {
    
      new Test();
     }
    
     private class Bar {
    
      int x = 10;
     }
    }

    A
    The code will fail to compile

    B
    10 10 10 10

    C
    20 20 20 20

    D
    10 20 10 20

    Note: Not available
    1. Report
  4. Question: Which class contains a method to create a directory?

    A
    File

    B
    DataOutput

    C
    Directory

    D
    FileDescriptor

    E
    FileOutputStream

    Note: Not available
    1. Report
  5. Question: What is the output of the given program?
    public class Test130 {
            public static void main(String[] args) {
                    A a = new A2();
                    B b = new B2();
                    System.out.println(a.a + """" + b.b());
            }
    }
    class A {
            public int a = 1;
    }
    class A2 extends A { 
            public int a = 2;
    }
    class B { 
            public int b() { return 1; }
    }
    class B2 extends B { 
            public int b() { return 2; }
    }

    A
    11

    B
    12

    C
    21

    D
    22

    Note: Not available
    1. Report
  6. Question: Which of the following is the correct syntax for suggesting that the JVM perform garbage collection?

    A
    System.setGarbageCollection();

    B
    System.out.gc();

    C
    System.gc();

    D
    System.free();

    Note: Not available
    1. Report
  7. Question: Why can't a Graphics object be created using the following statement? Graphics g = new Graphics();

    A
    The Graphics class is a final class.

    B
    The Graphics class is an abstract class.

    C
    The constructor of the Graphic class needs a color object to be passed as a parameter, e.g Graphics g = new Graphics(new Color());.

    Note: Not available
    1. Report
  8. Question: Select all correct statements:

    A
    Vector is synchronized, ArrayList is not synchronized

    B
    Hashtable is synchronized, HashMap is not synchronized

    C
    Vector is not synchronized, ArrayList is synchronized

    D
    Hashtable is not synchronized, HashMap is synchronized

    Note: Not available
    1. Report
  9. Question: What is the output of the given program?
    public class Test97 {
            public static void main(String[] args) {
                    int[][] a = new int[2][2];
                    System.out.println(a.length);
            }
    }

    A
    0

    B
    2

    C
    3

    D
    4

    Note: Not available
    1. Report
  10. Question: Which of the following is false?

    A
    A scrollable ResultSet can be created in JDBC 2.0 API.

    B
    The cursor is moved forward using next().

    C
    The cursor is moved backward using previous().

    D
    A while loop can be used because next() & previous() methods return false beyond the resultset.

    E
    A while loop can be used because next () & previous () methods return -1 beyond the resultset.

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd