Question 21 Statement Return Number Rows Two Dimensional Array Int Rows B Int Length C In Q13148635

Question 21

Which statement will return the number of rows in a twodimensional array a?

a.

int a = a.rows

b.

int a = a.length

c.

int a = a[i].length

d.

int a = a.size

2.5 points

Question 22

What statement(s) could you use to declare and instantiate anArrayList object reference of Book objects namedlibrary with a default capacity of 10 elements?

a.

ArrayList<Book > library = newArrayList<Book>();

b.

ArrayList<Book > library;

library = new ArrayList<Book>();

c.

both a and b

d.

neither a or b

2.5 points

Question 23

What method of an arraylist class object returns the number ofelements in an ArrayList object?

a.

size()

b.

capacity

c.

length

d.

length( )

2.5 points

Question 24

After the following code sequence is executed, what are thecontents at ArrayList index 1 in a?

ArrayList<Integer> a = newArrayList<Integer>( );
a.add( 7 );
a.add( 10 );
a.add( 21 );
a.set( 1, 4 );
a.remove( 0 );

a.

10

b.

7

c.

4

d.

21

2.5 points

Question 25

Which of the following is inherited by a subclass

a.

all instance variables and methods

b.

public instance variables and methods only

c.

protected instance variables and methods only

d.

protected and public instance variables and methods

2.5 points

Question 26

Public Constructor methods

a.

Are inherited by but cannot be accessed by a subclass

b.

Are inherited by and can be accessed with the super keyword by asubclass

c.

Are accessible with the super keyword by a subclass but are notinherited

d.

Are not inherited by and cannot be accessed by a subclass

2.5 points

Question 27

Assuming the class B extends class A, then

a.

An object of class B is an object of class A

b.

An object of class A is an object of class B

c.

Both a and b

d.

None of the above

2.5 points

Question 28

What is the output of this code sequence?

Scanner parse = newScanner(“AA%:BB:CC”);
parse.useDelimiter(“:”);
while(parse.hasNext())
{

System.out.print(parse.next() + “”);
System.out.println();

}

a.

AA%
:BB
:CC

b.

AA% BB CC

c.

AA%
BB
CC

d.

None of the above

2.5 points

Question 29

It is legal to have more than one catch block to matcha try block but you must have a finally block if there ismore than one catch block.

True

False

2.5 points

Question 30

Assuming file data.txt exists and is successfully opened andcontains the following text

CS1

What does the file data.txt contain after this code sequence isexecuted?

try
{
FileOutputStream fos = new FileOutputStream(“data.txt “, false);
PrintWriter pw = new PrintWriter( fos );
pw.println( “Java Illuminated”);
    
pw.close( );
}
catch( IOException ioe )
{

ioe.printStackTrace( );

}

a.

Java Illuminated

b.

CS1Java Illuminated

c.

CS1
Java Illuminated

d.

Java Illuminated
CS1

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *