Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 1 When saving your Java source code for class HighClass the name of the

ID: 3684899 • Letter: Q

Question

QUESTION 1

When saving your Java source code for class HighClass the name of the file must be:

highclass.class

highclass.java

HighClass.class

HighClass.java

1 points   

QUESTION 2

When you successfully compile the Java source file for the class HighClass, the following bytecode file is created:

highclass.class

HighClass.class

HighClass.javac

HighClass.java

1 points   

QUESTION 3

Which of these is not a primitive data type?

character

double

int

boolean

1 points   

QUESTION 4

Given two declared and initialized int variables a and b and a double variable c, which of the following statements would result in successfully assigning a double precision value to c without losing precision?

c = (double) a / b;

c = a / (double) b;

c = (double) ( a / b);

a and b and c

Only a and b

1 points   

QUESTION 5

What is the output of the following code sequence:

1.5

50

1500

None of the above

1 points   

QUESTION 6

What is the output of the following code sequence:

a = a

a = 4.0

a = 4.8

1 points   

QUESTION 7

Which of the following code sequences will calculate the total of three int variables a, b and c and print the correct result in sum?

Both a and b

1 points   

QUESTION 8

To instantiate an object reference named d1 of class SimpleDate using the default constructor you could use the statement(s):

SimpleDate d1 = new SimpleDate();

Both a and b

Neither a or b

1 points   

QUESTION 9

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

public void foo( int x, String s)

Which method call(s) would be correct assuming both a and y are integer values and assuming each statement is complete?

1 points   

QUESTION 10

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

public char foo( int i, String s, double c )

Which method call(s) could be correct assuming a is an int and y is an int and each statement is complete?

char c = Quiz.foo( 1, “Hmmm!”, 0.1 );

All of the above

1 points   

QUESTION 11

Class HighClass is included in package users.myclasses . To access any static methods of this class in my application class the following statement would be required at the start of my application.

package users.myclasses.HighClass

include users.myclasses.HighClass

class users.myclasses.HighClass

import users.myclasses.HighClass

1 points   

QUESTION 12

What is the output of the following code sequence?

Read a book

Go sailing

none of the above

1 points   

QUESTION 13

What is the output of the following code sequence?

a space is printed

W

Hello

o

1 points   

QUESTION 14

What is the output of the following code sequence?

D or Lower

Done

1 points   

QUESTION 15

What is the output of the following code sequence?

Season is Fall
Season is Winter
Season is Spring

End of Seasons

Season is Summer
Season is Fall
Season is Winter
Season is Spring

Season is Summer

1 points   

QUESTION 16

Given the following code declaring and initializing three boolean variables x, y and z with respective values true, true, and false, does the following expression evaluate to true or false?

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

Expression:   ((x || y) && !z)

True

False

1 points   

QUESTION 17

Given the following code declaring and initializing three boolean variables x, y and z with respective values true, true, and false, does the following expression evaluate to true or false?

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

Expression:   ((x && z) || y)

True

False

1 points   

QUESTION 18

Given the following code declaring and initializing two int variables x and y with respective values 19 and 17, does the value of the expression evaluate to true or false.

int x = 19;
int y = 17;

Expression:   x > y || !( x>y )

True

False

1 points   

QUESTION 19

Given the following code declaring and initializing two int variables x and y with respective values 19 and 17, does the value of the expression evaluate to true or false.

int x = 19;
int y = 17;

Expression:   y >= 17

True

False

1 points   

QUESTION 20

Given the following code declaring and initializing two int variables x and y with respective values 19 and 17, does the value of the expression evaluate to true or false.

int x = 19;
int y = 17;

Expression:    ( x - 2 == y ) && ( y>x )

True

False

1 points   

QUESTION 21

Assuming a class name SimpleDate, you could save your class source file with the following name(s):

simpleDate.java

simpledate.java

SimpleDate.java

Any of the above

1 points   

QUESTION 22

Which of the following is not an existing wrapper class?

Char

Integer

Float

Double

1 points   

QUESTION 23

What statement(s) will access the static constant PI of the Math class assuming x is a double?

x = Math.PI();

x = Math.PI;

both a and b

none of the above

1 points   

QUESTION 24

Given two boolean expressions a and b, are the following expressions equivalent?

!( a && b )
!a || !b

True

False

1 points   

QUESTION 25

What is the output of this code sequence?

Hello 1
Done

Hello 1
Hello 2
Done

Hello 3
Done

Hello 3
Hello 4
Done

1 points   

QUESTION 26

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

i is 9
product is 336

i is 8
product is 42

i is 8
product is 14

i is 10
product is 3024

1 points   

QUESTION 27

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

int i = 0;
int sum = 0;
for ( i = 0; i < 40; i++)

{

if ( i % 10 = = 0)

sum += i ;

}

i is 40
sum is 60

i is 39
sum is 40

i is 40
sum is 40

i is 39
sum is 60

1 points   

QUESTION 28

If you want to execute a loop body at least once, what type of looping structure would you use?

for loop

while loop

do/while loop

none of the above

1 points   

QUESTION 29

What is the output of this code sequence? (The user successively enters 3, 5, and -1.)

System.out.print( “Enter an int > “ );
int i = scan.nextInt( );
while ( i != -1)

{

System.out.print( “Enter an int > “ );
i = scan.nextInt( );
System.out.println( “Hello” );

}

Enter an int > 3
Hello
Enter an int > 5
Hello
Enter an int > -1

Hello
Enter an int > 3
Hello
Enter an int > 5
Hello
Enter an int > -1

Enter an int > 3
Enter an int > 5
Hello
Enter an int > -1
Hello

none of the above

1 points   

QUESTION 30

True or false. You can simulate a for loop with a while loop?

True

False

1 points   

QUESTION 31

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

int i = 0;
int sum = 0;
while ( i < 7 )
{

sum += i;
++i;

}

i is 6
sum is 21

i is 8
sum 21

i is 7
sum is 21

i is 6
sum is 15

1 points   

QUESTION 32

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

public static double foo( float f )

What can you say about the method foo?

it is an instance method

it is a class field

it is a class method

it is an instance variable

1 points   

QUESTION 33

To instantiate an object instance of class SimpleDate assuming an overloaded SimpleDate class constructor requiring 3 int parameters exists, which statement(s) could be used to instantiate an object of type SimpleDate?

SimpleDate s1 = SimpleDate(1, 2, 3);

SimpleDate s2 = new SimpleDate(1, 2, 3);

SimpleDate s3 = new SimpleDate();

b and c

1 points   

QUESTION 34

What is the value of i and how many times will the word “Hello” have printed after this code sequence is executed?

int i = 0;
for( i = 0; i < =2; i++)
{

System.out.println( "Hello");

}

i is 2
Hello prints 2 times

i is 3
Hello prints 3 times

i is 2
Hello prints 3 times

i is 3
Hello prints 2 times

1 points   

QUESTION 35

What is output after the following code sequence is executed?

piF and piD are equal
piF and piD are not equal

piF and piD are equal
piF and piD are considered equal

piF and piD are not equal
piF and piD are not equal

piF and piD are not equal
piF and piD are considered equal

a.

highclass.class

b.

highclass.java

c.

HighClass.class

d.

HighClass.java

Explanation / Answer

Question 1

Answer: d.   HighClass.java

Question 2

Answer: b.   HighClass.class

Question 2

Answer: b.   HighClass.class

Question 3

Answer: a.   character

Question 4

Answer: e.   Only a and b

Question 5

Answer: b.   50

Question 6

Answer: d.   a = 4.8

Question 7

Answer:   d.   Both a and b

Question 8

Answer: c.   Both a and b

Question 9

Answer: b.   Both b and c

Question 10

Answer: d.   All of the above

Question 11

Answer: d.   import users.myclasses.HighClass

Question 12

Answer: b.   Go sailing

Question 13

Answer: a.   a space is printed

Question 14

Answer: d.   D or Lower Done

Question 15

Answer: b.   End of Seasons

Question 16

Answer: True

Question 17

Answer: False

Question 18

Answer: True

Question 19

Answer: True

Question 20

Answer: False

Question 21

Answer: c. SimpleDate.java

Question 22

Answer: a.   Char

Question 23

Answer: b.   x = Math.PI;

Question 24

Answer: False

Question 25

Answer: d.   Hello 3 Hello 4 Done

Question 26

Answer: d.   i is 10 product is 3024


Question 27

Answer: a.   i is 40 sum is 60

Question 28

Answer: c.   do/while loop

Question 29

Answer: c.  
Enter an int > 3
Enter an int > 5
Hello
Enter an int > -1
Hello

Question 30

Answer: True

Question 31

Answer: c.  
i is 7
sum is 21

Question 32

Answer: c.   it is a class method

Question 33

Answer: d.   b and c

Question 34

Answer: c.   i is 2 Hello prints 3 times

Question 35

Answer: d.  
piF and piD are not equal
piF and piD are considered equal

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote