What is y after the following statement is executed? x = -1; y = (x < 0) ? -2 : 3; a. -3 b. -2 с. 3 d. e. Illegal expression 12. What is the output of the following code? boolean even = false; System.out.printIn((even ? "true" : "false")); a. true b. false c. nothing d. true false

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Answer 10 to 12

11. What is y after the following statement is executed?
x = -1;
y = (x < 0) ? -2 : 3;
а.
-3
b.
-2
с.
3
d.
e. Illegal expression
12. What is the output of the following code?
boolean even = false;
System.out.println((even ? "true" : "false"));
a. true
b. false
c. nothing
d. true false
13. What is Math.floor(3.6)?
а.
3.0
b.
3
с.
4
d.
5.0
14. Which of the following assignment statements is correct?
char c = 'dn';
char c = 100;
char c = 'm';
a.
b.
с.
d.
char c = "100";
15. Which of the following are valid identifiers?
a.
$failure
b.
public
с.
988ht
d.
8=9
е.
radius
Transcribed Image Text:11. What is y after the following statement is executed? x = -1; y = (x < 0) ? -2 : 3; а. -3 b. -2 с. 3 d. e. Illegal expression 12. What is the output of the following code? boolean even = false; System.out.println((even ? "true" : "false")); a. true b. false c. nothing d. true false 13. What is Math.floor(3.6)? а. 3.0 b. 3 с. 4 d. 5.0 14. Which of the following assignment statements is correct? char c = 'dn'; char c = 100; char c = 'm'; a. b. с. d. char c = "100"; 15. Which of the following are valid identifiers? a. $failure b. public с. 988ht d. 8=9 е. radius
7. To obtain the are sine of 0.5 degree, use
Math.asin(0.5)
Math.asin(Math.toDegrees(0.5))
Math.asin(Math.toRadians(0.5))
Math.sin(0.5)
a.
b.
с.
d.
8. What is the value of the following expression?
true || true && false
true
false
а.
b.
9. What is y displayed in the following code?
public class Testl {
public static void main(String[] args) {
int x = 1;
int y = x = x + 1;
System.out.println("y is " + y);
}
}
a. y is 0.
b. y is 1 because x is assigned to y first.
c. y is 2 because x + 1 is assigned to x and then x is assigned to y.
d. The program has a compile error since x is redeclared in the statement int y = x = x +1
10. Analyze the following program fragment:
int x;
double d = 1.5;
switch (d) {
case 1.0: x = 1;
case 1.5: x = 2;
case 2.0: x = 3;
Which of these is correct about the above code?
The program has a compile error because the required break statement is missing
in the switch statement.
The program has a compile error because the required default case is missing in
the switch statement.
a.
b.
с.
The switch control variable cannot be double.
d.
No errors.
Transcribed Image Text:7. To obtain the are sine of 0.5 degree, use Math.asin(0.5) Math.asin(Math.toDegrees(0.5)) Math.asin(Math.toRadians(0.5)) Math.sin(0.5) a. b. с. d. 8. What is the value of the following expression? true || true && false true false а. b. 9. What is y displayed in the following code? public class Testl { public static void main(String[] args) { int x = 1; int y = x = x + 1; System.out.println("y is " + y); } } a. y is 0. b. y is 1 because x is assigned to y first. c. y is 2 because x + 1 is assigned to x and then x is assigned to y. d. The program has a compile error since x is redeclared in the statement int y = x = x +1 10. Analyze the following program fragment: int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3; Which of these is correct about the above code? The program has a compile error because the required break statement is missing in the switch statement. The program has a compile error because the required default case is missing in the switch statement. a. b. с. The switch control variable cannot be double. d. No errors.
Expert Solution
Step 1

let us see the answer:-

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education