Java Find the Output Questions - Data Types

🎓 Check Out My Top 25 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare

Here are 10 Java code snippets designed to test your understanding of Java data types. Each question includes a code snippet and multiple-choice options for the output. After you complete the test, you can check your score, the correct answer, and an explanation.

1. What will be the output of the following Java code?

int a = 100;
int b = 200;
System.out.println(a + b);
a) 100200
b) 300
c) Compilation error
d) None of the above

2. What will be the output of the following Java code?

System.out.println(10 / 4);
a) 2
b) 2.5
c) 2.0
d) None of the above

3. What will be the output of the following Java code?

double num = 1.0 / 2.0;
System.out.println(num);
a) 0.5
b) 0
c) 1
d) 0.50

4. What will be the output of the following Java code?

char letter = 'A' + 1;
System.out.println(letter);
a) A
b) B
c) 66
d) None of the above

5. What will be the output of the following Java code?

System.out.println(11 % 6);
a) 5
b) 6
c) 1
d) 11

6. What will be the output of the following Java code?

boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun && isFishTasty);
a) true
b) false
c) Compilation error
d) None of the above

7. What will be the output of the following Java code?

int x = 10;
int y = ++x;
System.out.println(x + ", " + y);
a) 10, 11
b) 11, 11
c) 11, 10
d) 10, 10

8. What will be the output of the following Java code?

byte b = 126;
b += 1;
b += 1;
System.out.println(b);
a) 128
b) -128
c) 127
d) -126

9. What will be the output of the following Java code?

double pi = 3.14159;
double radius = 10.0;
System.out.println(pi * radius * radius);
a) 314.159
b) 314.16
c) 315
d) 314

10. What will be the output of the following Java code?

System.out.println("1" + 2 + 3);
a) "123"
b) "6"
c) "15"
d) None of the above

My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:

Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare