KEMBAR78
Operators in Java (10.03.2025) | PDF | Boolean Data Type | Computer Programming
0% found this document useful (0 votes)
20 views32 pages

Operators in Java (10.03.2025)

The document contains a series of Java programming questions and their corresponding outputs, focusing on operators, control statements, and performance. Each question is followed by multiple-choice options, with instructions to insert the correct option number in the designated column. The document emphasizes not changing any default column names and provides a structured format for responses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views32 pages

Operators in Java (10.03.2025)

The document contains a series of Java programming questions and their corresponding outputs, focusing on operators, control statements, and performance. Each question is followed by multiple-choice options, with instructions to insert the correct option number in the designated column. The document emphasizes not changing any default column names and provides a structured format for responses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Operator

NOTE :
1) Please don’t change any column name which is present by default.
2) In Correct Answer Column, Just insert the option number which is correct. (F

S. No. Question
1 Modulus operator, %, can be applied to which of these?

What will be the output of the following Java program?

class increment
{
public static void main(String args[])
{
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4);

}
2 }

What will be the output of the following Java program?

class Modulus
{
public static void main(String args[])
{
double a = 25.64;
int b = 25;
a = a % 10;
b = b % 10;
System.out.println(a + " " + b);
}
3 }
What will be the output of the following Java program?

class increment
{
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
4 }

What will be the output of the following Java program?

class Output
{
public static void main(String args[])
{
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
b++;
++a;
System.out.println(a + " " + b + " " + c);
}
5 }
What will be the output of the following Java code?

class operators
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
int var3;
var3 = ++ var2 * var1 / var2 + var2;
System.out.print(var3);
}
6 }

What will be the output of the following Java code?

class operators
{
public static void main(String args[])
{
int x = 8;
System.out.println(++x * 3 + " " + x);
}
7 }

What will be the output of the following Java code?

class Output
{
public static void main(String args[])
{
int x=y=z=20;

}
8}
Which of these lines of Java code will give better
performance?

1. a | 4 + c >> b & 7;
9 2. (a | ((( 4 * c ) >> b ) & 7 ))
What will be the output of the following Java program?

class Output
{
public static void main(String args[])
{
int a,b,c,d;
a=b=c=d=20
a+=b-=c*=d/=20
System.out.println(a+" "+b+" "+c+" "+d);

}
10 }
11 What is the output of relational operators?

What will be the output of the following Java code?

class Relational_operator
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2);
}
12 }

What will be the output of the following Java code?

class bool_operator
{
public static void main(String args[])
{
boolean a = true;
boolean b = !true;
boolean c = a | b;
boolean d = a & b;
boolean e = d ? b : c;
System.out.println(d + " " + e);
}
13 }
What will be the output of the following Java code?

class ternary_operator
{
public static void main(String args[])
{
int x = 3;
int y = ~ x;
int z;
z = x > y ? x : y;
System.out.print(z);
}
14 }

What will be the output of the following Java code?

class Output
{
public static void main(String args[])
{
int x , y = 1;
x = 10;
if (x != 10 && x / 0 == 0)
System.out.println(y);
else
System.out.println(++y);
}
15 }

What will be the output of the following Java code?

class Output
{
public static void main(String args[])
{
boolean a = true;
boolean b = false;
boolean c = a ^ b;
System.out.println(!c);
}
16 }
What will be the output of the following Java program?

class bitwise_operator
{
public static void main(String args[])
{
int var1 = 42;
int var2 = ~var1;
System.out.print(var1 + " " + var2);
}
17 }

What will be the output of the following Java program?

class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
18 }

What will be the output of the following Java program?

class leftshift_operator
{
public static void main(String args[])
{
byte x = 64;
int i;
byte y;
i = x << 2;
y = (byte) (x << 2)
System.out.print(i + " " + y);
}
19 }
What will be the output of the following Java program?

class rightshift_operator
{
public static void main(String args[])
{
int x;
x = 10;
x = x >> 1;
System.out.println(x);
}
20 }

What will be the output of the following Java program?

class Output
{
public static void main(String args[])
{
int a = 1;
int b = 2;
int c = 3;
a |= 4;
b >>= 1;
c <<= 1;
a ^= c;
System.out.println(a + " " + b + " " + c);
}
21 }

22 Which of these statements are incorrect?

23 Which of the following option leads to the portability an


24 Which of the following is not a Java features?

25 The \u0021 article referred to as a


26 _____ is used to find and fix bugs in the Java programs
27 Which of the following is a valid declaration of a char?
Evaluate the following Java expression, if x=3, y=5,
and z=10:

28 ++z + y - y + z + x++
Which of the following tool is used to generate API
documentation in HTML format from doc comments in
29 source code?

What is the output of the following program ?


class Numbers{
public static void main(String args[]){
int a=20, b=10;
if((a < b) && (b++ < 25)){
System.out.println("This is any
language logic");
}
System.out.println(b);
}
30 }
Operators and Control Statements In Java

present by default.
on number which is correct. (For e.g. If Option 2 is correct answer then please enter 2)

Option 1 Option 2
Integers Floating – point numbers

11 01

5.640000000000001 5 5.640000000000001 5.0


25 24

324 323
10 11

24 8 24 9

compile and runs fine 20

will give better


performance as it has no
parentheses will give better performanc
compile time error runtime error
Integer Boolean

0 1

False False True True


0 1

1 2

0 1
42 42 43 43

72 77

0 64 64 0
10 5

316 223
Assignment operators are
more efficiently
implemented by Java run- Assignment operators run
time system than their faster than their
equivalent long forms equivalent long forms
The applet makes
Bytecode is
the Java code secure
executed by JVM
and portable
Dynamic Architecture Neutral
Unicode escape
Octal escape
sequence
JVM JRE
char ch = '\utea'; char ca = 'tea';

24 23

avap tool javaw command

12 11
Statements In Java

2 is correct answer then please enter 2)

Option 3 Option 4
Both Integers and floating – point numbers None of the mentioned

1.5 1 1.5 1.0

55 5 5.640000000000001
32 33

234 344
12 56

27 8 27 9

run time error compile time error

Both 1 & 2 will give equal performance Dependent on the compute


a=20 b=0 c=20 d=1 none of the mentioned
Characters Double

1 0

True False False True


3 4

Runtime error owing to division by zero in if cUnpredictable behavior of program

0 1
42 -43 42 43

75 52

0 256 256 0
2 20

234 236

Assignment operators can be used only with


numeric and character data type None of the mentioned
Dynamic binding
Use of exception handling
between objects
Use of pointers Object-oriented
Hexadecimal Line feed
JDK JDB
char cr = \u0223; char cc = '\itea';

20 27

Javadoc tool javah command

10 Compilation Error
Correct Answer
3

1
3

4
3

3
3
2

FALSE

4
3

3
3

4
2

1
3

1
4
1

You might also like