Self Test With Answers

1) Which of the following is not a Java reference type
a) interface
b) array
c) class
d) primitive                                                     ( d )

2)  Arrays do not have one of the following features in
common with classes

a) declaration, instantiation and assignment
b) use of the new operator
c) use of references
d) ability to define custom methods                            ( d )

3 ) Place the following steps in the order they would occur.

a ) initialization
b) instantiation
c ) declaration
d) assignment      ___   ___   ___   ___          ( c, a, b, d )

4) Which of the following features is not found in arrays

a) a final variable called length
b) an offset index starting at 0
c) a way to increment an arrays size as needed
d) default value assignments                                        ( c )

5) Which of the following will not compile

a) String s =new String[8];
b) short [2] k;
c) byte b[ ] = new byte{ 2,2,};
d) long[] l =new long{ 3L,4L, 5L };                                 ( b )
 
 

6. The following example  is the same as which of the following?

    Example int [] x, [ ] l;

a )  int [] x;
      int [] l;

b )  int [][] x;
      int [][] l;

c )  int [] x;
       int [][] l;

d )  int [][] x;
       int [] l;                                                                           ( c )
 

7. Which of the following is not legal?

a) byte []gallons[]= new byte{ 44,33,22 };
b) byte []quart[]=new byte[22][11];
c) byte pints[][]=new byte[11][ ];
d) byte [][] liters={ {1}, {2} };                                                ( a )    
 

8. Which of the following is not legal?

a)  Object[] obee1=new Object[]{ "String", "9" };
b)  Object[] obee2= {"X",vector,array};
c ) Object[] obee3= { new Integer( 9 ), new Integer(11) };
d ) Object[] obee4= { "tractor" ,91823 };                          ( d )