Question: answer them all Question 20 Given an array int a [][] = new int[3][4] ,how do you access the element of array a located in

answer them all

Question 20

Given an array int a [][] = new int[3][4] ,how do you access the element of array a located in the third row and the fourth column?

a.

a[3][4]

b.

a( 2,3 )

c.

a{3}{4}

d.

a[2][3]

2.5 points

Question 21

Which statement will return the number of rows in a two dimensional 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 an ArrayList object reference of Book objects named library with a default capacity of 10 elements?

a.

ArrayList library = new ArrayList();

b.

ArrayList library;

library = new ArrayList();

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 of elements 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 the contents at ArrayList index 1 in a?

ArrayList a = new ArrayList( ); 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 a subclass

c.

Are accessible with the super keyword by a subclass but are not inherited

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 = new Scanner("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 match a try block but you must have a finally block if there is more than one catch block.

True

False

2.5 points

Question 30

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

CS1

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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!