You are on page 1of 4

UNIT III

One mark

1. Which of the following is a relational operator in Java?

a. + b. = c.== d.&&

2. Which of the following operators is used to perform equality comparison in Java?


a) + b) = c)== d)&&

3. Operator used to perform left shift

a) << b)>> c) && d) !

4. Print the output

int a = 5;
int b = 7;
System.out.println((a > b) ? "a is greater than b" : "a is less than or equal to b");
a) a is greater than b
b) a is less than or equal to b
c) compilation error
d) runtime error

5. Evaluate 6+3*2

a) 12 b)13 c)18 d) 36

6. Write the value : 7%3

a)1 b)2 c)3 d)7

7. Write the unary operator

a) + b)- c)* d) /

8. Write the result of the expression true && false

a) true b)false c)true false d) None

9. Write the output for 3<<2

a) 6 b)9 c)8 d)12

10. Operator used for string concatenation in java


a) * b)+ c)&& d) /

5 Marks

1. Define operators and its types


2. Explain about arithmetic operators in java with example
3. Write a program to multiply two numbers
4. Describe about expression with example
5. Write in detail about relational operators with example

10 marks
1. Describe about any 3 types of operators in java
2. Write a program to find greatest of two numbers using conditional operator
3. Write short notes on expression and its precedencies
4. Explain about logical, assignment and bitwise operators in java with example
5. Write a program to find area of rectangle
UNIT IV
One Mark

1. Write the output


int i = 0;
while (i < 3) {
System.out.print(i + " ");
i++;
}
a. 0 1 2 b. 0 0 1 c. 0 1 2 3 d. 1 2 3

2. Print the output


int x = 5;
int y = 10;
if (x < y) {
System.out.println("x is less than y");
} else {
System.out.println("x is greater than or equal to y");
}
a. x is less than y
b. x is greater than or equal to y
c. Compilation error
d. Runtime error

3. Write the output


int a = 5;
int b = 2;
int c = a / b;
System.out.println(c);
a. 2 b. 2.5 c. 3 d. Error
4. Statement only checks for equality is ___________
a) If b) Switch c)if & switch d) None

5. ____________ are selection statements in java


a) If b)continue c)breakd)switch

6. Break and continue are __________ statements


a) Selection b) Jumping c) Control d) None

7. The loop that executes the body of the loop atleast once is _____
a) While d)do while c)for d)switch

8. _________ statement is used to skip the iteration of loop


a) Continue b)break c)for d) none

9. Write the output


While(true){
System.ou.print(“hai”)}
a) Hai……. b) prints hai infinite c)Error d) None

10. Write the use of break statement


a) Stops the iteration b) Skips the iteration c) Error d) none

5 marks
1. Explain in detail about the types of if statement
2. Write a program to find greatest of two numbers using if statement
3. Describe about while loop with example
4. Write a program to find the year is leap year or not
5. Explain about switch statement with example
10 marks
1. Write in detail about the if statement with example
2. Explain in detail about the looping with proper example
3. Write a program to print the summation of even numbers
4. Write a program to print student mark list with nested if statement
5. Write a program to find sum of digits
6. Differentiate break and continue
7. Write a program to find summation of n numbers

You might also like