Logo
Question DetailsNormal
$ 25.00
What is the value of balance after the following code is executed?
Question posted by
request

Need answer to the following test. Some of them are multiple options, while some don't.  Please make sure to read every question carefully.

Thanks

Here are the questions

What is the value of balance after the following code is executed?

int balance = 10;
while (balance >= 1) {
  if (balance < 9) {
continue;
  }
  balance = balance - 9;
}

Question 1 options:

0

2

The loop does not end

1

-1


Save Question 2 (1 point)  

What is the output of the following Java code: ______________________.
public class Quizzes { 
  public static void main(String args[]){
       double length = 81;
       double width = 144;
      System.out.println(Math.sqrt(length) + Math.sqrt(width));     
   }
}
 

Question 2 options:
Save Question 3 (1 point)  

Analyze the following code.

    int x = 0;
    if (x > 0);
    {
      System.out.println("x");
    }
 

Question 3 options:

The symbol x is never printed.

The value of variable x is printed once.

No output is produced.

The symbol x is printed once.
Save Question 4 (1 point)  

How many times with the string hi be printed after executing the following code? 
public class Quizzes { 
  public static void main(String args[]){  
       int colCnt = 0;
       int rowCnt = 0;
    do  {       
       colCnt = 0;        
      do  {
         System.out.print("hi" + "t");            
             colCnt++;
       } while (colCnt < 8);           
        System.out.print("n");
            rowCnt++;
        } while (rowCnt < 7);
   }
}
 

Question 4 options:
Save Question 5 (1 point)  

What is the output of the following Java code?  ___________________
public class Quizzes { 
  public static void main(String args[]){            
    String string1 = "CMIS141 ";
    String string2 = "is all";
    String string3 = "about Java!";
    String concat = string3.concat(string2).concat(string1);    
    System.out.println(concat.length());
   }
}

Question 5 options:
Save Question 6 (1 point)  

In the following Java code, what is the largest possible value that could be printed while executing the following code?
// Import 
import java.util.Random;

public class Quizzes { 
  public static void main(String args[]){      
      // create random object
      Random randomNo = new Random();   
      for (int i=0; i<10000; i++) { 
    System.out.println(randomNo.nextInt(100));
      }  
   }
}

Question 6 options:
Save Question 7 (1 point)  

What is the output of the following Java code? ____________________

public class Quizzes { 
  public static void main(String args[]){            
    String string1 = "243";    
    String string2 = "true";
    String string3 = "24.1"    ;
    boolean results = (Boolean.parseBoolean(string2) && false);
    System.out.println(results);
   }
}

Question 7 options:
Save Question 8 (1 point)  

Analyze the following code.

    int x = 1;
    while (0 < x) && (x < 100)
      System.out.println(x++);

Question 8 options:

The code does not compile because the loop body is not in the braces.

The loop runs for ever.

The number 1 to 99 are displayed.

The number 2 to 100 are displayed.

The code does not compile because (0 < x) & (x < 100) is not enclosed in a pair of parentheses.
Save Question 9 (1 point)  

What is the output of the following fragment?

int i = 1;
int j = 1;
while (i < 5) {
  i++;
  j = j * 2;  
}
System.out.println(j);

Question 9 options:

32

64

4

16

8


Save Question 10 (1 point)  

What is the value of the variable cnt after the following code is executed?
public class Quizzes { 
  public static void main(String args[]){  
    int cnt = 0;
    for (int rowCnt=0; rowCnt <= 4; rowCnt++) {      
      for (int colCnt=0; colCnt<= 4; colCnt++) {
        cnt++;                 
       }
    }    
   }
}

Question 10 options:
Save Question 11 (1 point)  

How many times does the following loop iterate?
public class Quizzes { 
  public static void main(String args[]){  
    int cnt = 1;
    int maxLoop = 30;          
    while (cnt < maxLoop) {              
            cnt++;
        }
   }
}

Question 11 options:
Save Question 12 (1 point)  

Which of the following values would read using the Scanner nextShort() without producing an error?

Question 12 options:

32768

-32768

-100000

100000

None of the above
Save Question 13 (1 point)  

What is the output of the following Java code? ____________________
public class Quizzes { 
  public static void main(String args[]){            
    String string1 = "243";        
    System.out.println(Integer.parseInt(string1));
   }
}
 

Question 13 options:
Save Question 14 (1 point)  

What is the output of the following Java code:  ____________________.

public class Quizzes { 
  public static void main(String args[]){
       double examAvg = 85.9983;      
       System.out.println(Math.ceil(examAvg));     
   }
}
 

Question 14 options:
Save Question 15 (1 point)  

Which of the loop statements always have their body executed at least once.

Question 15 options:

The while loop

The do-while loop

The for loop

None of the above
Save Question 16 (1 point)  

What is the output of the following Java code: ______________________.

public class Quizzes { 
  public static void main(String args[]){      
      double angle = 90;
      angle = Math.toRadians(angle);   
      System.out.println(Math.sin(angle) + Math.pow(Math.cos(angle),2));      
   }
}

Question 16 options:
Save Question 17 (1 point)  

How would you construct an instance of scanner class that will read from the standard input (keyboard) in Java?

Question 17 options:

Scanner scannerIn = new ScannerIn();

Scanner myOut = new Scanner();

Scanner myOut = new Scanner(Standard.Input);

Scanner myOut = new Scanner(Standard.io);

None of the above
Save Question 18 (1 point)  

According to the Google style guide, Java variable and class names should be named using UpperCamelCase.

Question 18 options:

True

False
Save Question 19 (1 point)  

The following Java code contains valid brace placement according to the Google style guide

public class MyClass {    
    public static void main(String[] args) 
    {
    System.out.println("Welcome to CMIS 141");
    } // End of main
} // End class

Question 19 options:

True

False
Save Question 20 (1 point)  

What package do you need to import to use the Scanner class in Java?

Question 20 options:

java.util

java.Lang

java.io

java.nio

None of the above
Save Question 21 (1 point)  

Which of the following expression yields an integer between 0 and 100, inclusive?

Question 21 options:

(int)(Math.random() * 101)

int)(Math.random() * 100)

(int)(Math.random() * 100) + 1

(int)(Math.random() * 100 + 1)
Save Question 22 (1 point)  

Using the Google style guide document, select the proper declaration of a Java constant.

Question 22 options:

int CONSTANT SPEED = 3.0;

double final SPEED = 3.0;

float FINAL speed = 3.0;

Final SPEED = 3.0;

None of the above


Save Question 23 (1 point)  

How many times does the following loop iterate?

public class Quizzes { 
  public static void main(String args[]){  
    int cnt = 1;
    int maxLoop = 30;          
    do {                  
            cnt++;
        }while (cnt < maxLoop) ;
   }
}
 

Question 23 options:
Save Question 24 (1 point)  

Analyze the following two code fragments.
(i)
    int x = 5;
    if (0 < x) && (x < 100)
      System.out.println("x is between 1 and 100");
(ii)
    int x = 5;
    if (0 < x && x < 100)
      System.out.println("x is between 1 and 100");

Question 24 options:

The first fragment has a syntax error on the second line.

The second fragment has a syntax error on the second line.

Both fragments produce the same output.

Both fragments compile, but produce different result.

None of the above.
Save Question 25 (1 point)  

What Java data type is returned while calling the nextGaussian() method in the java.util.Random class?

Question 25 options:
Save

Available Solution
$ 25.00
What is the value of balance after the following code is executed?
  • This solution has not purchased yet.
  • Submitted On 30 Jan, 2018 02:06:44
Solution posted by
solution
Q1) c : This loop does not end Q 2) 21.0 Q 3) D : The symbol x is printed once. Q 4) 56...
Buy now to view full solution.
attachment
Attachment


Other Related Solutions
closebutton

$ 629.35