1. What is the output of the following Java code ? int a=3, b=-3, c=0; if (a > = c){ if (b != -3) System.out.println("X"); System.out.println("Z"); } System.out.println("Y"); else else Z X 2. The Java expression: (3+2)*4 Can be also written as: (3*4+2*4) Incorrect Correct 3. The following Boolean expression: (x || !x) Will always give : 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
Question
100%

H3-(1) Basic Java Syntax. (self learning quiz)

 

Introduction to Java Programming.

 

-You can add //comments for a better understanding. explanation throw

 

-Explanation through with answers.

 

-Please answer without abbreviation.

 

-Make it clean and clear typing/writing.

 

Thank you.

 

 

 

1. What is the output of the following Java code ?
int a=3, b=-3, c=0;
if (a >= c){
if (b != -3)
System.out.println("X");
System.out.println("Z"); }
System.out.println("Y");
else
else
Y
Z
X
2. The Java expression:
(3+2)*4
Can be also written as:
(3*4+2*4)
Incorrect
3. The following Boolean expression:
Correct
(x || !x)
Will always give :
true
4. What is the output of the following Java code ?
int x=0;
x=(4-2*3)+5%4-2;
System.out.println(x);
false
5. The following Boolean expression:
-1
!(!(!(!x)))
Is equivalent to:
6. The following Boolean expression :
!x
!(X<5)
else
Is most equivalent to:
else
x!=5
x==5
x>=5
7. Given the following Java code, what will be the final value of variable k ?
int k=4, j;
k--;
if (k%5==0)
x>5
j=9;
else if (k%7==0)
j=28;
else
j=7;
switch (k) {
case 9:
--k;
break;
case 28:
++k;
break;
default:
k=k*2;
break;}
8. What is the output of the following Java code ?
int a=4, b=3, c=2;
System.out.println("The result is = "+(++a*(c+8)/5-4*b--));
6
The result is = 0
The result is = -4
The result is = -2
9. What is the output of the following Java code ?
int h=2, f=0, m = -2;
The result is = 2
if ((h >= m ^ h<m) && !(f != 0))
System.out.println("H");
System.out.println("L");
H
10. What is the output of the following Java code ?
int year=2008;
if ((year % 4 = = 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println(year+" is a leap year !");
System.out.println(year+" is NOT a leap year !");
2008 is a leap year !
2008 is NOT a leap year !
11. What is the output of the following Java code?
int num=0;
num--;
System.out.println(num*-1);
Transcribed Image Text:1. What is the output of the following Java code ? int a=3, b=-3, c=0; if (a >= c){ if (b != -3) System.out.println("X"); System.out.println("Z"); } System.out.println("Y"); else else Y Z X 2. The Java expression: (3+2)*4 Can be also written as: (3*4+2*4) Incorrect 3. The following Boolean expression: Correct (x || !x) Will always give : true 4. What is the output of the following Java code ? int x=0; x=(4-2*3)+5%4-2; System.out.println(x); false 5. The following Boolean expression: -1 !(!(!(!x))) Is equivalent to: 6. The following Boolean expression : !x !(X<5) else Is most equivalent to: else x!=5 x==5 x>=5 7. Given the following Java code, what will be the final value of variable k ? int k=4, j; k--; if (k%5==0) x>5 j=9; else if (k%7==0) j=28; else j=7; switch (k) { case 9: --k; break; case 28: ++k; break; default: k=k*2; break;} 8. What is the output of the following Java code ? int a=4, b=3, c=2; System.out.println("The result is = "+(++a*(c+8)/5-4*b--)); 6 The result is = 0 The result is = -4 The result is = -2 9. What is the output of the following Java code ? int h=2, f=0, m = -2; The result is = 2 if ((h >= m ^ h<m) && !(f != 0)) System.out.println("H"); System.out.println("L"); H 10. What is the output of the following Java code ? int year=2008; if ((year % 4 = = 0 && year % 100 != 0) || (year % 400 == 0)) System.out.println(year+" is a leap year !"); System.out.println(year+" is NOT a leap year !"); 2008 is a leap year ! 2008 is NOT a leap year ! 11. What is the output of the following Java code? int num=0; num--; System.out.println(num*-1);
Expert Solution
steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Top down approach design
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.
Similar questions
  • SEE MORE QUESTIONS
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