# Revision
---
title: Quiz 1
description: Quiz 1
duration: 60
card_type: quiz_card
---
# Question
**1.** Which of the following is NOT a boolean expression?
# Choices
- [ ] true
- [ ] 4 == 5
- [ ] 4 + 5
- [ ] 4 < 5
- [ ] false
---
title: Quiz 2
description: Quiz 2
duration: 60
card_type: quiz_card
---
# Question
**2.** Predict the output:
```
if(5 > 10) {
System.out.println("First if");
}
if(10 >= 16) {
System.out.println("Second if");
}
System.out.println("Oops!! Nothing will get printed..");
```
# Choices
- [ ] First if
- [ ] Second if
- [ ] First if<br>Second if<br>Oops!! Nothing will get printed..
- [ ] Oops!! Nothing will get printed..
---
title: Quiz 3
description: Quiz 3
duration: 60
card_type: quiz_card
---
# Question
**3.** Predict the output:
```
if(false){
System.out.println("Line 1");
} else {
System.out.println("Line 2");
}
```
# Choices
- [ ] Line 1
- [ ] Line 2
- [ ] Line 1<br>Line 2
- [ ] Error
---
title: Quiz 4
description: Quiz 4
duration: 60
card_type: quiz_card
---
# Question
**4.** Predict the output:
For input: 45 45
```
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if(a > b){
System.out.print(a);
}
else{
System.out.print(b);
}
```
# Choices
- [ ] Error
- [ ] 45<br>45
- [ ] 45
---
title: Quiz 5
description: Quiz 5
duration: 60
card_type: quiz_card
---
# Question
**5.** What will be the output of the following:
```
if(true) {
System.out.println("1");
}
else if(true) {
System.out.println("2");
}
else if(true) {
System.out.println("3");
}
```
# Choices
- [ ] 1
- [ ] 1<br>2<br>3
- [ ] 2
- [ ] 3
---
title: Quiz 6
description: Quiz 6
duration: 60
card_type: quiz_card
---
# Question
**6.** What will be the output of the following code?
```java
int a = 10,b = 10;
if(a >= 10 && b >= 10){
System.out.print(a+b);
}
```
# Choices
- [ ] 10
- [ ] 20
- [ ] 30
- [ ] None
---
title: Quiz 7
description: Quiz 7
duration: 60
card_type: quiz_card
---
# Question
**7.** What will be the output of the following code?
```java
int a = 10;
int b = 10;
if( ++a >= 12 && ++b >= 12 ){
System.out.println("Hello");
}
System.out.println(a + b);
```
# Choices
- [ ] Hello<br>10
- [ ] 22
- [ ] 21
- [ ] None
---
title: Quiz 8
description: Quiz 8
duration: 60
card_type: quiz_card
---
# Question
**8.** What will be the output of the following code?
```java
int a = 10;
int b = 10;
if( ++a >= 12 || ++b >= 12 ){
System.out.println("Hello");
}
System.out.println(a + b);
```
# Choices
- [ ] 20
- [ ] 21
- [ ] 22
- [ ] None
---
title: Quiz 9
description: Quiz 9
duration: 60
card_type: quiz_card
---
# Question
**9.** What will be the output of the following code?
```java
int N = 5;
if(N > 2)
System.out.println("Yayay");
System.out.println("Hmmmm");
else
System.out.println("Blahblah!!");
System.out.println("Blahblah!!");
```
# Choices
- [ ] Error
- [ ] No Error, this code works!
- [ ] Yayay<br>Hmmmm
- [ ] Blahblah!!<br>Blahblah!!
---
title: Quiz 10
description: Quiz 10
duration: 60
card_type: quiz_card
---
# Question
**10.** What will be the output of the following code?
```java
int marks = 80;
if(marks > 70) {
System.out.print("Distinction ");
System.out.print("Congrats ");
} else if(marks > 35) {
System.out.print("Pass ");
} else
System.out.print("Fail ");
System.out.print("Good luck");
```
# Choices
- [ ] Distinction Congrats Good luck
- [ ] Good luck
- [ ] Error
- [ ] Distinction Congrats
---
title: Quiz 11
description: Quiz 11
duration: 60
card_type: quiz_card
---
# Question
**11.** Predict the output of the following code?
```java
int a = 10, b = 15;
if(a > 8) {
if(a < b || b == 9) {
System.out.println("Hi");
}
else {
System.out.println("Bye");
}
}
else {
System.out.println("Good Bye");
}
```
# Choices
- [ ] Hi
- [ ] Bye
- [ ] Good Bye
- [ ] None
---
title: Quiz 12
description: Quiz 12
duration: 60
card_type: quiz_card
---
# Question
**12.** Predict the output of the following code?
```java
if(true) {
if(true) {
if(false) {
System.out.println("Hey there");
}
}
else {
System.out.println("Hello");
}
}
else {
System.out.println(10 / 0);
}
```
# Choices
- [ ] Hey there
- [ ] Hello
- [ ] No output
- [ ] Error
---
title: Quiz 13
description: Quiz 13
duration: 60
card_type: quiz_card
---
# Question
**13.** Predict the output of the following code:
```java
if(true){
int x = 10;
SOPln("Value of x is " + x);
x ++ ;
}
SOPln("Value of x is " + x);
```
# Choices
- [ ] Value of x is 10<br>Value of x is 11
- [ ] Value of x is 10<br>Value of x is 0
- [ ] Value of x is 10<br>Value of x is 10
- [ ] Error
---
title: Quiz 14
description: Quiz 14
duration: 60
card_type: quiz_card
---
# Question
**14.** Predict the output of the following code:
```java
int a = 10, b = 5;
if(true){
int c = a * b;
}
SOPln(c);
```
# Choices
- [ ] 50
- [ ] Error
- [ ] Need Coffee!!
---
title: Quiz 15
description: Quiz 15
duration: 60
card_type: quiz_card
---
# Question
**15.** What is the output of the following code?
```
int i = 0;
while(i <= 10){
System.out.print(i + " ");
i++;
}
```
# Choices
- [ ] 0 1 2 3 4 5 6 7 8 9 10
- [ ] 1 2 3 4 5 6 7 8 9 10
- [ ] Error
---
title: Quiz 16
description: Quiz 16
duration: 60
card_type: quiz_card
---
# Question
**16.** What is the output of the following code?
```
int i = 1;
while(i <= 10){
System.out.print(i + " ");
}
```
# Choices
- [ ] 1 2 3 4 5 6 7 8 9 10
- [ ] 1 1 1 1 1 1 ... loop never stops [infinite loop]
---
title: Quiz 17
description: Quiz 17
duration: 60
card_type: quiz_card
---
# Question
**17.** How many times `Hi` will be printed in the output?
```
int i = 0;
while(i <= 5){
System.out.println("Hi");
i = i + 1;
}
```
# Choices
- [ ] 5
- [ ] 6
- [ ] 4
- [ ] Infinite times
---
title: Quiz 18
description: Quiz 18
duration: 60
card_type: quiz_card
---
---
title: Quiz 18
description: Quiz 18
duration: 60
card_type: quiz_card
---
# Question
**18.** What will be the total number of iterations in the following code?
```
int i = 3;
while(i <= n){
System.out.println(i);
i = i + 3;
}
```
# Choices
- [ ] n / 3
- [ ] 3 * n
- [ ] n+3
- [ ] n
---
title: Quiz 19
description: Quiz 19
duration: 60
card_type: quiz_card
---
# Question
**19.** Predict the output:
```
int i = 10;
while(i >= 0){
System.out.print(i + " ");
i = i - 2;
}
```
# Choices
- [ ] 10 9 8 7 6 5 4 3 2 1 0
- [ ] 10 8 6 4 2
- [ ] 10 8 6 4 2 0
- [ ] 0 2 4 6 8 10
---
title: Quiz 20
description: Quiz 20
duration: 60
card_type: quiz_card
---
# Question
**20.** What is the output of the following code?
```
for(int i = 1; i >= 10; i++){
System.out.print(i + " ");
}
```
# Choices
- [ ] Error
- [ ] 1 2 3 4 5 6 7 8 9 10
- [ ] Nothing will get printed
- [ ] 10 9 8 7 6 5 4 3 2 1
---
title: Quiz 21
description: Quiz 21
duration: 60
card_type: quiz_card
---
# Question
**21.** What is the output of the following code?
```
for(int i = 1; i <= 5; i=i-1){
System.out.print(i + " ");
}
```
# Choices
- [ ] 1 2 3 4 5
- [ ] 5 4 3 2 1
- [ ] Infinite loop
---
title: Quiz 22
description: Quiz 22
duration: 60
card_type: quiz_card
---
# Question
**22.** What does the following code do :
```
int ans = 0;
for(int i = n; i > 0; i = i / 10) {
ans += 1;
}
SOPln(ans);
```
- [ ] counts the number of digits
- [ ] removes the last digit
- [ ] prints the last digit
- [ ] does nothing
---
title: Quiz 23
description: Quiz 23
duration: 60
card_type: quiz_card
---
# Question
**23.** What is the expected output for **N = 4**?
**Code**
```
for (int i = 1; i <= N; i++) {
for (int i = 1; i <= N; i++) {
SOP(" * ");
}
SOPln();
}
```
- [ ] \*\*\*\*
- [ ] \*<br>\*\*<br>\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*\*<br>\*\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*<br>\*\*<br>\*
---
title: Quiz 24
description: Quiz 24
duration: 60
card_type: quiz_card
---
# Question
**24.** What is the expected output for **N = 4**?
**Code**
```
public static void main() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
System.out.print(" * ");
}
}
```
- [ ] \*\*\*\*
- [ ] \*<br>\*\*<br>\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*\*<br>\*\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*<br>\*\*<br>\*
---
title: Quiz 25
description: Quiz 25
duration: 60
card_type: quiz_card
---
# Question
**25.** What is the expected output for **N = 4**?
**Code**
```
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= i; j++) {
SOP(" * ");
}
SOPln();
}
```
- [ ] \*\*\*\*
- [ ] \*<br>\*\*<br>\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*\*<br>\*\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*<br>\*\*<br>\*
---
title: Quiz 26
description: Quiz 26
duration: 60
card_type: quiz_card
---
# Question
**26.** What is the expected output for **N = 4**?
**Code**
```
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N - i + 1; j++) {
SOP(" * ");
}
SOPln();
}
```
- [ ] \*\*\*\*
- [ ] \*<br>\*\*<br>\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*\*<br>\*\*\*\*<br>\*\*\*\*
- [ ] \*\*\*\*<br>\*\*\*<br>\*\*<br>\*
---
title: Quiz 27
description: Quiz 27
duration: 60
card_type: quiz_card
---
# Question
**27.** What is the output of the following code?
```
static int sum(int a, int b){
return a + b;
}
public static void main(String args[]){
System.out.println(sum(5,10));
}
```
# Choices
- [ ] Error
- [ ] 15
- [ ] No output
---
title: Quiz 28
description: Quiz 28
duration: 60
card_type: quiz_card
---
# Question
**28.** What is the output of the following code?
```java
static void sum(int a, int b){
return a + b;
}
public static void main(String args[]){
System.out.println(sum(5,10));
}
```
# Choices
- [ ] Error
- [ ] 15
- [ ] No output
---
title: Quiz 29
description: Quiz 29
duration: 60
card_type: quiz_card
---
# Question
**29.** What is the output of the following code?
```
static int square(int a){
return a * a;
}
public static void main(String args[]){
System.out.println(square( - 6 ));
}
```
# Choices
- [ ] -36
- [ ] 36
- [ ] 6
- [ ] Error
---
title: Quiz 30
description: Quiz 30
duration: 60
card_type: quiz_card
---
# Question
**30.** What is the output of the following code?
```
public static int square(int x){
return x * x;
}
public static int add(int x, int y){
return x + y;
}
public static void main(String args[]){
int n1 = square(3);
System.out.println(add(n1,square(9)));
}
```
# Choices
- [ ] 81
- [ ] 9
- [ ] 90
- [ ] 115
---
title: Quiz 31
description: Quiz 31
duration: 60
card_type: quiz_card
---
# Question
**31.** What will be the output?
```
public static void test1(){
System.out.println("Hi");
System.out.println("Welcome");
}
public static void main(){
test1();
System.out.println("Home");
}
```
# Choices
- [ ] Hi<br> Welcome <br> Home
- [ ] Welcome<br>Home<br>Hi
- [ ] Home<br>Welcome<br>Hi
---
title: Quiz 32
description: Quiz 32
duration: 60
card_type: quiz_card
---
# Question
**32.** What will be the output?
```
public static void test2(){
System.out.println("Hi");
return;
}
public static void main(){
test2();
System.out.println("Hello");
}
```
# Choices
- [ ] Hi<br>Hello
- [ ] Hello <br>Hi
- [ ] Error
---
title: Quiz 33
description: Quiz 33
duration: 60
card_type: quiz_card
---
# Question
**33.** What will be the output?
```
public static boolean isEven(int N){
if(N % 2 == 0){
return true;
}else{
return false;
}
}
public static void main(){
System.out.println(isEven(60));
System.out.println("Hello");
}
```
# Choices
- [ ] true <br>Hello
- [ ] Hello<br>false
- [ ] false<br>Hello
---
title: Quiz 34
description: Quiz 34
duration: 60
card_type: quiz_card
---
# Question
**34.** What will be the output?
```
public static void EvenOdd(int N){
if(N % 2 == 0){
System.out.println("Even");
return;
}
System.out.print("Odd");
}
public static void main(){
EvenOdd(10);
System.out.println("Hello");
}
```
# Choices
- [ ] Even<br>Hello
- [ ] Odd Hello
- [ ] Hello
---
title: Quiz 35
description: Quiz 35
duration: 60
card_type: quiz_card
---
# Question
**35.** What will be the output?
```
public static int check(int N){
System.out.print(N+10);
}
public static void main(){
check(15);
}
```
# Choices
- [ ] 15
- [ ] Error
- [ ] No output
---
title: Quiz 36
description: Quiz 36
duration: 60
card_type: quiz_card
---
# Question
**36.** What will be the output?
```
public static int test(int n){
if(n % 2 == 0){
return 2;
}
if(n % 5 == 0){
return 5;
}
}
public static void main(){
int a = test(15);
}
```
# Choices
- [ ] 5
- [ ] Error
- [ ] 2
- [ ] No output
---
title: Quiz 37
description: Quiz 37
duration: 60
card_type: quiz_card
---
# Question
**37.** What will be the output?
```
public static int sum(int a, int b){
return a+b;
System.out.println("Hey");
}
public static void main(){
int x = 10, y = 20;
System.out.pritnln(sum(x,y));
}
```
# Choices
- [ ] Error
- [ ] 30
- [ ] Hey
---
title: Quiz 38
description: Quiz 38
duration: 60
card_type: quiz_card
---
# Question
**38.** What will be the output?
```
public static int sum(int a, int b){
int x = 20, y = 30;
return a+b;
}
public static void main(){
int a = 10, b = 5;
int x = 100, y = 200;
System.out.pritnln(sum(x,y));
}
```
# Choices
- [ ] 300
- [ ] 15
- [ ] Compilation error
---
title: Quiz 39
description: Quiz 39
duration: 60
card_type: quiz_card
---
# Question
**39.** What will be the output?
```
public static int sum(int a, int b){
a = 20; b = 30;
return a+b;
}
public static void main(){
int a = 10, b = 5;
int x = 100, y = 200;
System.out.pritnln(sum(x,y));
}
```
# Choices
- [ ] 50
- [ ] 300
- [ ] Compilation error
---
title: Quiz 40
description: Quiz 40
duration: 60
card_type: quiz_card
---
# Question
**40.** What will be the output?
```
public static int sum(int a, int b){
int a = 20, b = 30;
return a+b;
}
public static void main(){
int a = 10, b = 5;
int x = 100, y = 200;
System.out.pritnln(sum(x,y));
}
```
# Choices
- [ ] 50
- [ ] 300
- [ ] Error
---
title: Answers to quizzes
description:
duration: 60
card_type: cue_card
---
1. c) 4 + 5
2. d) Oops!! Nothing will get printed..
3. b) Line 2
4. c) 45
5. a) 1
6. b) 20
7. c) 21
8. c) 22
9. a) Error
10. a) Distinction Congrats Good luck
11. a) Hi
12. c) No output
13. d) Error
14. b) Error
15. a) 0 1 2 3 4 5 6 7 8 9 10
16. b) 1 1 1 1 1 1 ... loop never stops [infinite loop]
17. b) 6
18. a) n / 3
19. c) 10 8 6 4 2 0
20. c) Nothing will get printed
21. c) Infinite Loop
22. a) counts the number of digits
23. c) \*\*\*\*<br>\*\*\*\*<br>\*\*\*\*<br>\*\*\*\*
24. a) \*\*\*\*
25. b) \*<br>\*\*<br>\*\*\*<br>\*\*\*\*
26. d) \*\*\*\*<br>\*\*\*<br>\*\*<br>\*
27. b) 15
28. a) Error
29. b) 36
30. c) 90
31. a) Hi<br> Welcome <br> Home
32. a) Hi<br> Hello
33. a) true <br>Hello
34. a) Even<br>Hello
35. b) Error
36. b) Error
37. a) Error
38. a) 300
39. a) 50
40. c) Error