Question
Question 41 Which of the following is NOT a valid assignment statement? A. x = 55; B. 55 = x; C. x += 3; D.
Question 41 Which of the following is NOT a valid assignment statement? A. x = 55; B. 55 = x; C. x += 3; D. x = 56 + y;
Question 42 What is the result of 45 / 4? A. 11.25 B. 10 C. 12 D. 11 Question
43 What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0"); else System.out.println("x equals 0"); A. x is greater than 0 B. x is less than 0 C. x equals 0 D. None
Question 44 What is the exact output of the following code? double area = 3.5; System.out.print("area"); System.out.print(area); A. area3.5 B. area 3.5 C. 3.5 3.5 D. 3.53.5
Question 45 What does System.out.println("Welcome" + 1 + 1 * 2); print? A. Welcome3 B. Welcome11*2 C. Welcome12 D. Welcome4
Question 46 Which of the following is the best for generating random integer 0 or 1? A. (int)(Math.random() + 0.5) B. (int)Math.random() + 1 C. (int)Math.random() D. (int)(Math.random() + 0.2) Question 47 What is the printout of the following code: double x = 10.1; int y = (int)x; System.out.println("x is " + x + " and y is " + y); A. x is 10.0 and y is 10.0 B. x is 10.1 and y is 10.0 C. x is 10.1 and y is 10 D. x is 10 and y is 10
Question 48 You should fill in the blank in the following code with ________. public class Test { public static void main(String[] args) { System.out.print("The grade is "); printGrade(78.5); System.out.print("The grade is "); printGrade(59.5); } public static __________ printGrade(double score) { if (score >= 90.0) System.out.println('A'); else if (score >= 80.0) System.out.println('B'); else if (score >= 70.0) System.out.println('C'); else if (score >= 60.0) System.out.println('D'); els System.out.println('F'); } } A. void B. boolean C. double D. char Question 49 The ________ method parses a string s to an int value. A. Integer.parseInteger(s); B. Integer.parseInt(s); C. integer.parseInteger(s); D. integer.parseInt(s);
Question 50 Suppose x = 1, y = -1, and z = 1. What is the printout of the following code? if (x < 0) if (y < 0) System.out. println("x < 0 and y < 0"); else if (z < 0) System.out. println("x < 0 and z < 0"); else System.out. println("x < 0 and z > 0"); A. x > 0 and y > 0; B. x < 0 and z > 0; C. x < 0 and z < 0; D. no printout.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started