Similar Collections


    No collections found

questions

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

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


  1. 1, 2, 3, 4
  2. 1, 3, 4, 5
  3. 2, 4, 5, 6
  4. 3, 4, 5, 6
discuss
Which one of these lists contains only Java programming language keywords

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


  1. class, if, void, long, Int, continue
  2. goto, instanceof, native, finally, default, throws
  3. try, virtual, throw, final, volatile, transient
  4. strictfp, constant, super, implements, do
discuss
Which will legally declare, construct, and initialize an array

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


  1. int [] myList = {"1", "2", "3"};
  2. int [] myList = (5, 8, 2);
  3. int myList [] [] = {4,9,7,0};
  4. int myList [] = {4, 3, 7};
discuss
Which is a reserved word in the Java programming language

Which is a reserved word in the Java programming language?


  1. method
  2. native
  3. subclasses
  4. reference
discuss
Which is a valid keyword in java

Which is a valid keyword in java?


  1. interface
  2. string
  3. Float
  4. unsigned
discuss
Which three are valid declarations of a float

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;


  1. 1, 2, 4
  2. 2, 3, 5
  3. 1, 3, 6
  4. 2, 4, 6
discuss
Which is a valid declarations of a String

Which is a valid declarations of a String?


  1. String s1 = null;
  2. String s2 = 'null';
  3. String s3 = (String) 'abc';
  4. String s4 = (String) '\ufeed';
discuss
What is the numerical range of a char

What is the numerical range of a char?


  1. -128 to 127
  2. -(2^15) to (2^15) - 1
  3. 0 to 32767
  4. 0 to 65535
discuss
Which three are legal array declarations

Which three are legal array declarations?
1. int [] myScores [];
2. char [] myChars;
3. int [6] myScores;
4. Dog myDogs [];
5. Dog myDogs [7];


  1. 1, 2, 4
  2. 2, 4, 5
  3. 2, 3, 4
  4. All are correct.
discuss
Which three piece of codes are equivalent to line 3

Which three piece of codes are equivalent to line 3?
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;

public interface Foo 
{ 
    int k = 4; /* Line 3 */
}

  1. 1, 2 and 3
  2. 2, 3 and 4
  3. 3, 4 and 5
  4. 4, 5 and 6
discuss
Which one of the following will declare an array and initialize it with five numbers

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


  1. Array a = new Array(5);
  2. int [] a = {23,22,21,20,19};
  3. int a [] = new int[5];
  4. int [5] array;
discuss
Which three are valid declarations of a char

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';


  1. 1, 2, 4
  2. 1, 3, 6
  3. 3, 5
  4. 5 only
discuss
Which is the valid declarations within an interface definition

Which is the valid declarations within an interface definition?


  1. public double methoda();
  2. public final double methoda();
  3. static void methoda(double d1);
  4. protected void methoda(double d1);
discuss
What will be the output of the program

What will be the output of the program?

Note: The command-line invocation is
> java CommandArgsThree 1 2 3

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

  1. 0 0
  2. 1 2
  3. 0 0 0
  4. 1 2 3
discuss
What will be the output of the progra

What will be the output of the progra
Note: The command-line invocation is
> java CommandArgs 1 2 3 4

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[2] = " + s2);
    }
}

  1. args[2] = 2
  2. args[2] = 3
  3. args[2] = null
  4. An exception is thrown at runtime.
discuss
What will be the output of the program, if this code is executed with the command line

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

> java F0091 world

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

  1. Hello
  2. Hello Foo91
  3. Hello world
  4. The code does not run.
discuss
What will be the output of the program

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 { }

  1. null
  2. theDogs
  3. Compilation fails
  4. An exception is thrown at runtime
discuss
What will be the output of the program

What will be the output of the program ?

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

  1. 10, 9, 8, 7, 6,
  2. 9, 8, 7, 6, 5,
  3. Compilation fails.
  4. An exception is thrown at runtime.
discuss
What will be the output of the program

What will be the output of the program

Note: The command-line invocation is
> java CommandArgsTwo 1 2 3

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

  1. 0 1 2
  2. 1 2 3
  3. 0 0 0
  4. An exception is thrown at runtime
discuss
In the given program, how many lines of output will be produced

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 [3] [] [];
    int i, j;
    x[0] = new int[4][];
    x[1] = new int[2][];
    x[2] = new int[5][];
    for (i = 0; i < x.length; i++)
    {
        for (j = 0; j < x[i].length; j++) 
        {
            x[i][j] = new int [i + j + 1];
            System.out.println("size = " + x[i][j].length);
        }
    }
    }
}

  1. 7
  2. 9
  3. 11
  4. 13
discuss
total MCQs: 98

MCQs

98

Views

135

Best Answers

299

Points

5