Q.1.

What will be the output of the program?

public class CommandArgsThree 
{
    public static void main(String [] args) 
    {
        String [][] argCopy = new String[2][2];
        int x;
        argCopy[= args;
        x = argCopy[0].length;
        for (int y =y < x; y++) 
        {
            System.out.print(" " + argCopy[0][y]);
        }
    }
}

and the command-line invocation is

> java CommandArgsThree 1 2 3

Q.2.

What will be the output of the program?

public class CommandArgsTwo 
{
    public static void main(String [] argh) 
    {
        int x;
        x = argh.length;
        for (int y =y <= x; y++) 
        {
            System.out.print(" " + argh[y]);
        }
    }
}

and the command-line invocation is

> java CommandArgsTwo 1 2 3

Q.3.

What will be the output of the program?

public class CommandArgs 
{
    public static void main(String [] args) 
    {
        String s1 = args[1];
        String s2 = args[2];
        String s3 = args[3];
        String s4 = args[4];
        System.out.print(" args[= " + s2);
    }
}

and the command-line invocation is

> java CommandArgs 1 2 3 4

Q.4.

In the given program, how many lines of output will be produced?

public class Test 
{
    public static void main(String [] args) 
    {
    int [] [] [] x = new int [[] [];
    int i, j;
    x[= new int[4][];
    x[= new int[2][];
    x[= new int[5][];
    for (i =i < x.length; i++)
    {
        for (j =j < x[i].length; j++) 
        {
            x[i][j] = new int [i + j + 1];
            System.out.println("size = " + x[i][j].length);
        }
    }
    }
}
Q.5.

public class F{    
    public void main( String[] args ) 
    {  
        System.out.println( "Hello" + args[); 
    } 
}

What will be the output of the program, if this code is executed with the command line:

> java Fworld

Q.6.

Which one is a valid declaration of a boolean?

Q.7.

Which three are legal array declarations?

  1. int [] myScores [];
  2. char [] myChars;
  3. int [myScores;
  4. Dog myDogs [];
  5. Dog myDogs [7];
Q.8.

Which four options describe the correct default values for array elements of the types indicated?

  1. int -> 0
  2. String -> "null"
  3. Dog -> null
  4. char -> '\u0000'
  5. float -> 0.0f
  6. boolean -> true
Q.9.

What will be the output of the program?

public class X 
{
    public static void main(String [] args) 
    {
        String names [] = new String[5];
        for (int x=x < args.length; x++)
            names[x] = args[x];
        System.out.println(names[2]);
    }
}

and the command line invocation is

> java X a b

Q.10.

What will be the output of the program?


public class TestDogs 
{
    public static void main(String [] args) 
    {
        Dog [][] theDogs = new Dog[3][];
        System.out.println(theDogs[2][0].toString());
    }
}
class Dog { }
Q.11.

What will be the output of the program ?

public class Test 
{
    public static void main(String [] args) 
    {
        signed int x =        for (int y=y<y++, x--)
            System.out.print(x + ", ");
    }
}
Q.12.

Which three are valid declarations of a float?

  1. float f1 = -343;
  2. float f2 = 3.14;
  3. float f3 = 0x12345;
  4. float f4 = 42e7;
  5. float f5 = 2001.0D;
  6. float f6 = 2.81F;
Q.13.

Which is a valid declarations of a String?

Q.14.

public interface Foo 
{ 
    int k =/* Line 3 */
}
Which three piece of codes are equivalent to line
  1. final int k = 4;
  2. public int k = 4;
  3. static int k = 4;
  4. abstract int k = 4;
  5. volatile int k = 4;
  6. protected int k = 4;
Q.15.

Which one of these lists contains only Java programming language keywords?

Q.16.

What is the numerical range of a char?

Q.17.

Which one of the following will declare an array and initialize it with five numbers?

Q.18.

Which will legally declare, construct, and initialize an array?

Q.19.

Which three are valid declarations of a char?

  1. char c1 = 064770;
  2. char c2 = 'face';
  3. char c3 = 0xbeef;
  4. char c4 = \u0022;
  5. char c5 = '\iface';
  6. char c6 = '\uface';
Q.20.

Which is the valid declarations within an interface definition?