Question: Answer the Questions(Multiple Choice ): Question 6 To instantiate an object reference named d1 of class SimpleDate assuming the following constructor method headers: public SimpleDate()

Answer the Questions(Multiple Choice):

Question 6

To instantiate an object reference named d1 of class SimpleDate assuming the following constructor method headers:

public SimpleDate() public SimpleDate( int mm, int dd, int yyyy )

Which statement(s) would be valid and sufficient to instantiate an object of type SimpleDate:

a.

SimpleDate d1;

b.

SimpleDate d1 = new SimpleDate();

c.

SimpleDate d1;

d1 = new SimpleDate( 7, 4, 1776);

d.

b and c

2.5 points

Question 7

What is the output of the following code sequence?

int dice = 5;

switch ( dice ) { case 1: System.out.println( One); break; case 2: case 3: System.out.println( Two or Three); break; case 4: System.out.println( Four); break; case 5: case 6: System.out.println( Five or better); break; default: System.out.println( Off the chart); } System.out.println( Exit Switch );

a.

Five or better Off the chart Exit Switch

b.

Exit Switch

c.

Five or better Exit Switch

d.

Five or better Off the chart

2.5 points

Question 8

What are the values of i and product after this code sequence is executed?

int i = 6; int product = 1; do {

product *= i; i++;

} while (i < = 9 );

a.

i is 9 product is 3024

b.

i is 9 product is 336

c.

i is 10 product is 336

d.

i is 10 product is 3024

2.5 points

Question 9

Given the following code declaring and initializing three boolean variables x, y and z with respective values false, false, and false, answer question 9 indicating whether the value of the expression is true or false.

boolean x = false; boolean y = false; boolean z = false;

Expression: x || !z

True

False

2.5 points

Question 10

What is the output of this code sequence?

boolean x = true; boolean y = false; for ( int i = 0; i < 2; i++)

System.out.println( Hello );

if( x && y)

System.out.println( Done );

else

System.out.println( Shall we go sailing? );

a.

Hello Hello Shall we go sailing?

b.

Hello Hello Hello Shall we go sailing?

c.

Hello Hello Hello Done

d.

Hello Done Hello Done Hello Done

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!