Which of the following statements correctly outputs the names of voters who live
ID: 3870018 • Letter: W
Question
Which of the following statements correctly outputs the names of voters who live in district 6 and all voters who live in district 7 o if (district 17) O if (district s 6 11 district7 O if (district ss6 &&districts7; 0 if (6-1 district 7) System.out.printin("Name is" name) System.out.printin("Name is··name): System.out.printin"Name is name): System.out.printin"'Name is name) QUESTION 6 Assuming a variable w has been assigned the value 15, what does the following statement do? O assigns 15 to w Oassigns 2 tox assigns 0 to x O nothing QUESTION 7 What is the output of the following code segment? in, t=0; if (t 7) System.out print AAA") System.out printC 888") O nothingExplanation / Answer
Question 5 :
The statement which correctly output the names of voters who live in district 6 and all the voters who live in district 7 is :
if(district==6 && district==7)
System.out.println(“Name is “ +name );
This is the conditional if statement which tests multiple conditions like names of voters in district 6 and 7 by using logical operator &&.
Question 6 :
Assigns 2 to x
The function of the statement w==15 ? x=2 : x=0; is it assigns 2 to x .
Because w is assigned to value 15 , The given statement checks the condition , Since it is true value of x is 2.
Question 7 :
Output : BBB
int t=0;
if(t<7)
System.out.println(“AAA”);
System.out.println(“BBB”);
The value of t is 0 , Since t is lesser than 7 when compared by if statement , The last print statement line “ BBB “ will be printed in output .
Question 8 :
False
The value of Y assigned is 6 , The value of condition !(Y<7) is False because it describes the value of negation of Y<7 , since Y<7 is true its negation is false.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.