1) Given the following initial values: boolean flag1 = true, flag2 = false; int
ID: 3703037 • Letter: 1
Question
1) Given the following initial values:
boolean flag1 = true,
flag2 = false;
int num1 = 5,
num2 = 25;
What would the following test condition evaluate to?
(num1 > num2 || flag1)
2) Using the same variable values from the previous question,
what would the following test condition evaluate to?
( num2 / num1 == num1 && flag2 )
3) Using the same variable values from the previous questions,
what would the following test condition evaluate to?
( !flag2 && num1 + 20 <= num2)
4) Given that integer variable num is initialized to: 8 + 26 % 4
What is the value of num after the following code runs?
num *= 5;
5) Given the following code definition:
Scanner input = new Scanner(System.in);
And the user input:
Denver, Broncos
What would the value will be stored in the String variable stuff be, after the following statement runs?
stuff = input.next();
6) Using the same user input and Scanner as in the previous question,
what if the following statement was run instead of the previous one?
What would the value of character variable ch be after it runs?
ch = input.next().charAt(0);
7) Given the code:
If, above the code fragment,
num is initialized to 80
data is initialized to 5
What will the final value of num be after this code fragment runs?
8) Using the same switch statement code from the previous question
If, above the code fragment,
num is initialized to 40
data is initialized to 3
What will the final value of num be after this code fragment runs?
9) Using the same switch statement code from the previous questions
If, above the code fragment,
num is initialized to 50
data is initialized to 4
What will the final value of num be after this code fragment runs?
10) Given the code:
If integer variable num1 contains 8
and integer variable num2 contains 15,
what will integer variable answer contain after this code runs?
11) Given the code:
If, above the code fragment,
count is initialized to 10 and
testVal is initialized to 30
What will the final value of count be after this code fragment runs?
12) Using the code from the previous question,
if, above the code fragment,
count is initialized to 24 and
testVal is initialized to 50
What will the final value of count be after this code fragment runs?
13) Given the following method definition:
what value will be returned when the call passes in 5 for num and 4 for max ?
14) A _______________ automatically translates high-level language programs into executable programs.
15) A variable ___________________ is a statement that specifies the variable's name and datatype.
16) Given:
double floatVal = 84.2632;
Write ONE Java output statement that displays the floatVal variable value as shown below, ending with a newline
(since you must use the defined variable, the value 84 cannot be hard-coded in the output statement).
What is 84?
17) Given:
int num = 42;
char ch = 'x';
Write ONE Java output statement that displays the variables defined above within the following output, ending with a newline
(since you must use the defined variables, the values 042 and x cannot be hard-coded in the output statement).
It is 042 x two
18) Given the String variable sentence containing:
"Introduction to Programming"
What would be returned by the call:
sentence.indexOf("duct");
19) Given the same String variable sentence defined in the previous question, and the variable:
String word;
Write code that would extract the letters "rod" from the String sentence and store it into the String word.
20) Given the following code:
Write the code to call the displaySum() method from the main() method, using the defined variables.
What code is missing from the BLUE highlighted area?
22) Given the following variables:
int speed; // internet speed in Mbps
String quality; // description of the speed quality
Assume a value has been stored into the speed variable.
Write Java code to store "poor" into the quality String when the internet speed is below 50,
"excellent" when the internet speed is over 200,
and "average" otherwise, using the most efficient statement possible.
23) In your own words, explain the difference between source code and machine code, and how each is created.
Explanation / Answer
Hi friedn, As per the chegg policy, please post only 4 parts of Big Question.
I have answered first 4 with great details.
boolean flag1 = true, flag2 = false;
int num1 = 5, num2 = 25;
1. What would the following test condition evaluate to?
(num1 > num2 || flag1)
num1 > num2 = false and flag1 = true
S0, flase || true = true
Ans: true
2) what would the following test condition evaluate to?
( num2 / num1 == num1 && flag2 )
num2 / num1 = 5,
num2 / num1 == num1 => true
flag2 = false
So, true && false = false
Ans: false
3) what would the following test condition evaluate to?
( !flag2 && num1 + 20 <= num2)
!flag2 = true
num1 + 20 <= num2 => 25 <= 25 => true
So, true && true = true
Ans: true
4) Given that integer variable num is initialized to: 8 + 26 % 4
What is the value of num after the following code runs?
num = 8 + 26 % 4
= 8 + 2
= 10
Now, num *= 5;
=> num = num*5
num = 10*5
Ans: 50
Please DONT forgot to rate my answer. We are working hard for you Guys!!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.