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

What will the value of x be after the following statements are executed? double

ID: 3876877 • Letter: W

Question

What will the value of x be after the following statements are executed?

double a, b, c, x;
a = 5;
b = 3;
c = 6;
if ( a <= c ){

x = 1;

} else if ( c > b ) {

x = 2;

} else {

x = 3;

}

Question 2

What will the value of x be after the following statements are executed?

double a, b, c, x;
a = 5;
b = 3;
c = 6;
if ( a <= c ) {

x = 1;

}

if ( c > b ) {

x = 2;

}

if ( x > b ) {

x = 3;

}

Question 3

Which of the following is NOT a Java relational operator?

Question 4

Which of the following is true?

When using == to compare reference variables, you are testing for "identity equality" -- that the two variables refer to the same object.

The .equals() method tests for "content equality" -- that the objects are considered equivalent to each other.

Question 5

What symbols does Java use to create block statements (a 'block' of code)?

Question 6

Which of the following operators may NOT be used with operands of type boolean?

Question 7

What is a common use for a variable of type boolean?

Question 8

What is a common name for a method that returns type boolean?

Question 9

Which of the following data types is NOT valid for the switch expression in a switch instruction?

Question 10

If a break statement is not included at the end of each action (alternative) in a switchinstruction, what is the result?

Question 11

The switch instruction is a more general-purpose (more versatile) tool than the ifinstruction.

Question 12

You are writing a program that will allow a user to enter a single word identifying her 'sign' in the Chinese zodiac (e.g. "Dog") and then show some information about that sign. Obviously a decision must be made in this program. Which selection structure(s) could you use?

Question 13

What numerical value for x will cause the following expression to evaluate to true.

x > 5 || x < 9

Question 14

Which of the following is a legal Java expression?

Question 15

Which of the following operators has the highest precedence?

Question 16

Which of the following is true in Java?

I. Every else must have a preceding if.
II. Every if must have a following else.

Question 17

What kind of loop is a data validation loop?

Question 18

Which loop control structure can NOT be used if there are conditions under which the body of the loop should be executed zero times?

Question 19

You know that a for loop is usually the best choice for a counting loop, but which other loop control structure(s) could possibly be used to create a counting loop?

Question 20

Consider the following class definition:

public class Woog{

public static void main (String[] a){

Fiddle f = new Fiddle();

...

}

}

How would you describe the relationship between Fiddle and Woog?

A 0

Explanation / Answer

Q1. What will the value of x be after the following statements are executed?

double a, b, c, x;
a = 5;
b = 3;
c = 6;
if ( a <= c ){
x = 1;
} else if ( c > b ) {
x = 2;
} else {
x = 3;
}

Answer : B (1)
Explanation : First it check the condition if(a <= c) i.e.
if (5<=6), it will return true, so we'll get answer as 1 and
the loop will come outside.

Q2. What will the value of x be after the following statements are executed?

double a, b, c, x;
a = 5;
b = 3;
c = 6;
if ( a <= c ) {
x = 1;
}
if ( c > b ) {
x = 2;
}
if ( x > b ) {
x = 3;
}

Answer : A (2)
Explanation : first it checks if(a <= c) i.e if (5<=6) which returns true so value of X will be 1,
again it will check next condition if (c > b) i.e. if (6 > 3) which is also true so now x will hold
value as 2 then it will check next condition if (x>b) i.e if(2>3) which returns false
so value of X will be 2.

Q3 Which of the following is NOT a Java relational operator?
Answer : A (=)
Explanation : A ( = ) beacuse = is the assignment operator this is not a relational operator

Q4. Which of the following is true?
When using == to compare reference variables, you are testing for "identity equality" -- that the two variables refer to the same object.
The .equals() method tests for "content equality" -- that the objects are considered equivalent to each other.
Answer : C (I & II are both true)
Explanation : "==" operator is meant for the checking the equality of the object and the .equals() method is meant for the contenet comparision.

Q5 What symbols does Java use to create block statements (a 'block' of code)?
Answer : A ({} )
Explanation : () this used for the method declaration .
[] this is used for the array initialization. then the { } this is used for the block declaration.

Note : According to chegg policy i have solve first 4 question with additional 1 question.

Thanks.

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