Question: Answer the Questions(Multiple Choice ): Question 1 Assuming a StringIndexOutOfBoundsException exception class exists, what is the output of this code sequence? try { String word

Answer the Questions(Multiple Choice):

Question 1

Assuming a StringIndexOutOfBoundsException exception class exists, what is the output of this code sequence?

try

{

String word = new String("Java");

System.out.println( word.charAt( 4 ) );

}

catch( StringIndexOutOfBoundsException e )

{

System.out.println( OOPS! );

}

finally

{

System.out.println( OOPS! again );

}

a.

OOPS!

b.

a

OOPS! again

c.

a

d.

OOPS!

OOPS! again

2.5 points

Question 2

In the method header public static void main( String [ ] args )

a.

variable identifier args is an array of type String

b.

variable identifier args could contain arguments passed to method main from the command line

c.

Both a and b

d.

None of the above

2.5 points

Question 3

In a typical class, what is the general recommendation for access modifiers?

a.

Instance variables are are private and methods are private

b.

Instance variables are private and methods are public

c.

Instance variables are public and methods are private

d.

Instance variables are public and methods are public

2.5 points

Question 4

What is the output of the following code sequence:

double a = 27 % 11; System.out.println( a );

a.

297.0

b.

2.0

c.

5.0

d.

2.45

2.5 points

Question 5

In the Quiz class, the foo method has the following API:

public static double foo( int i)

Assuming x is an integer value, and assuming the following statement having been executed:

Quiz q = new Quiz();

which method call(s) could be used?

a.

double i = Quiz.foo( x );

b.

System.out.println( Foo has returned the double value: + q.foo( x));

c.

both a and b

d.

neither a or b

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!