0% found this document useful (0 votes)
26 views

practice test-1(operators)

Uploaded by

sapnadgh985
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

practice test-1(operators)

Uploaded by

sapnadgh985
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

REVISION-OPERATORS

(I) The size of '\n' is: [2025 SPECIMEN]


(a) 2 bytes
(b) 4 bytes
(c) 8 bytes
(d) 16 bytes

II) Identify the operator that gets the highest precedence while evaluating the given
expression:
[2025-SPECIMEN]
a+b%c*d–e
(a) +
(b) %
(c) –
(d) *
III) Evaluate the given expression when the value of a = 2 and b = 3.
[2025 SPECIMEN]
b *= a++ – ++b + ++a;
System.out.println(“a = ” + a);
System.out.println(“b = ” + b);

IV) The expression which uses >= operator is known as:


[2024 SPECIMEN]
1. relational
2. logical
3. arithmetic
4. assignment
V) Ternary operator is a: [2024 SPECIMEN]
1. logical operator
2. arithmetic operator
3. relational operator
4. conditional operator
VI) Evaluate the expression when the value of x = 2: [2024 SPECIMEN]
x = x++ + ++x + x

VII) if (a>b&&b>c) then largest number is: [2024 paper]


(a) b
(b)C
(c)a
(d) wrong expression

viii) Identify the type of operator &&:


1. ternary
2. unary
3. logical
4. relational
ix) Predict the output of the following code snippet: [2024]
String P = "20", Q ="22";
int a = Integer.parseInt(P);
int b = Integer.valueOf(Q);
System.out.println(a + " " + b);
1. 20
2. 20 22
3. 2220
4. 22
X) Evaluate the expression when the value of x = 4:
x *= --x + x++ + x
XI) Rewrite the following code using the if-else statement:
[2023]
int m = 400;
double ch = (m>300) ? (m / 10.0) * 2 : (m / 20.0) - 2;

XII)Predict the output int a[]={1,2,3,4,5}


System.out.println(a[1]+’ ‘+a[4])
a)1 5 b)15 c)40 d)none of these

xiii) What will be the output of the following code snippet?


int a = 10, b = 20;
System.out.println(a + b * 2);
a) 60 b) 50 c) 100 d) 40

xiv) The statement System.out.println(“six”+3+3); gives the output


a) six 33 b) 33 six c) six 6 d) 6 six
xv) What is the value of the expression 5 / 2 when both operands are of type int?
a) 2.5 b) 2 c) 2.0 d) 2.25

xvi)The statement (1>0)||(1<0)evaluates to


a)0 b)1 c)false d)true
xvii) Evaluate the expression when x is 4:
x += x++ * ++x % 2;

xviii) What is the result of the logical AND operator (&&) if both operands are true?
a) true b) false c) 1 d) 0
xix) What is the result of the logical AND operator (&&) if both operands are true?
a) true b) false c) 1 d) 0
xx) ) Which of the following is not a compound assignment operator?
a) += b) /= c) %= d) ==
xxi) Given the java statement System.out.println(a>b && b!=c) what will be the output if
a=6, b=4,c=4
a)true b)2 c)false d)14

xxii) System.out.println(true || false && false);


(A) true (B) false (C) Compilation error (D) None of the
above

xxiii) int x = 5, y = 10;


int result = x > y ? x + 2 : y - 2 * x;
System.out.println(result);
(A) 7 (B) 8 (C) 0 (D) -5
xxiv) int x = 4;
x *= 3 + 2;
a)20 b)12 c)14 d)compilation error
xxv) System.out.println(10 + 20 + "Java" + 5 * 2);
(A) 30Java10 (B) 10Java205 (C) 30Java25 (D) Compilation error

You might also like