2023 QUESTION 1 In Java the symbol and the symbol are used synonymously interchangeably True False QUESTION 2 Given | Assignment Collections

Computer Science 2023 P1 JAVA

2023 QUESTION 1 In Java the symbol and the symbol are used synonymously interchangeably True False QUESTION 2 Given | Assignment Collections

QUESTION 1

  1. In Java, the symbol “=” and the symbol “==” are used synonymously (interchangeably). 

True
False

   

QUESTION 2

  1. Given the following code, where x = 0, what is the resulting value of x after the for-loop terminates?
                for (int i=0;i<5;i++)
                      x += i;

    A.0B.4C.5D.10

   

QUESTION 3

  1. The following loop is syntactically valid.
          for (int j = 0; j < 1000; j++) j–;

    True
    False

   

QUESTION 4

  1. It is possible to convert any type of loop (while, do, or for) into any other.  True
    False

  

QUESTION 5

  1. If x is an int where x = 0, what will x be after the following loop terminates?
                while (x < 100)
                      x *= 2;

2

64

100

128

none of the above, this is an infinite loop

 

QUESTION 6

  1. Consider the following switch statement where x is an int. If x is currently equal to 3, what will the value of x be after the switch statement executes?
    switch (x)
         {
     case 3 : x += 1;
     case 4 : x += 2;
     case 5 : x += 3;
     case 6 : x++;
     case 7 : x += 2;
     case 8 : x–;
     case 9 : x++;
         }

A- 6

B-  11

C- 10

D- 12

  

QUESTION 7

  1. A switch statement must have a default clause. True
    False

   

QUESTION 8

  1. How many times will the following loop iterate?
     int x = 0;
     do  {
     System.out.println(x);
     x++;
     } while (x > 0 && x<10);

    A.1 timeB.9 timesC.10 timesD.11 times

  

QUESTION 9

  1. Control in a switch statement jumps to the first matching case. True
    False

1.5 points   

QUESTION 10

  1. The following for-loop is an infinite loop.
          int i; for (int j = 0; j < 1000; ) i++;

    True
    False

 

QUESTION 11

  1. Assume that count is 0, total is 20 and max is 1.  The following statement will do which of the following?  if (count != 0 && total / count > max)  max = total / count;
    A- The condition short circuits and the assignment statement is not executed
    B- The condition short circuits and the assignment statement is executed without problem
    C- The condition does not short circuit causing a division by zero error
    D- The condition short circuits so that there is no division by zero error when evaluating the condition, but the assignment statement causes a division by zero error

   

QUESTION 12

  1. The break statement does which of the following?

A- ends the program

B- transfers control out of the current control structure such as a loop or switch statement

C- ends the current line of output, returning the cursor

D- denotes the ending of a switch statement

E- indicates the end of line when using System.out.print

 

QUESTION 13

  1. The do loop differs from the while loop in that

A- the while loop will always execute the body of the loop at least once

B- the do loop will always execute the body of the loop at least once

C- the do loop will continue to loop while condition in the while statement is false and the while loop will continue to loop while the condition in the while statement is true

D- the while loop will continue to loop while condition in the while statement is false and the do loop will continue to loop while the condition in the while statement is true

E- none of the above, there is absolutely no difference between the two types of loops

QUESTION 14

  1. Of the following if-statements, which one correctly executes three instructions if the condition is true?

if (x < 0)
    a = b * 2;
    y = x;
    z = a – y;

{
if (x < 0)
    a = b * 2;
    y = x;
    z = a – y;
}if { (x < 0)
   a = b * 2;
   y = x;
   z = a – y ;
}

if (x < 0)
{
a = b * 2;
y = x;
z = a – y;
   }

  

QUESTION 15

  1. How many times will the following loop iterate?
     int x = 0;
     while (x > 0 && x<10)
     {
     System.out.println(x);
     x++;
     }

    A.0 timesB.1 timeC.9 timesD.10 times

QUESTION 16

  1. Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?
    if (x > 0) x++;

else x–;

if (x > 0) x++;

else if (x < 0) x–;

if (x > 0) x++;

if (x < 0) x–;

else x = 0;

if (x == 0) x = 0;

else x++;

x–;

E) x++;

x–;

QUESTION 17

  1. Assume that x and y are int variables with x = 5, y = 3, and a and d are char variables with a = ‘a’ and d = ‘A’, and examine the following conditions:
                Condition 1:  (x < y && x > 0)
                Condition 2:  (a != d || x != 5)
                Condition 3:  !(true && false)
                Condition 4:  (x > y || a == ‘A’ || d != ‘A’)

    All 4 Conditions are true, Only Condition 2 is true,  Condition 2 and Condition 4 are true only, Conditions 2, 3 and 4 are all true, Condition 1 is not,  All 4 Conditions are false

 

QUESTION 18

  1. You might choose to use a switch statement instead of nested if-else statements ifthe variable being tested might equal one of several hundred int valuesthe variable being tested might equal one of only a few int valuesthere are two or more int variables being tested, each of which could be one of several hundred valuesthere are two or more int variables being tested, each of which could be one of only a few valuesnone of the above, you would never choose to use a switch statement in place of nested if-else statements under any circumstance

1.5 points   

QUESTION 19

  1. The statement if (a >= b) a++; else b–; will do the same thing as the statement if (a < b) b–; else a++;. True
    False

   

QUESTION 20

  1. Consider the following switch-statement where x is an int. If x is currently equal to 5, what will the value of x be after the switch statement executes?

    switch (x)
         {
     case 3 : x += 1;
     case 4 : x += 2;
     case 5 : x += 3;
     case 6 : x++;
     case 7 : x += 2;
     case 8 : x–;
     case 9 : x++;
         }

    A.8B.6C.11D.5

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational