WorksheetsOperator and expressions in Java
Total questions: 34
Worksheet time: 34mins
Evaluate the following expression, if the values of the variables are a = 2, b = 3 and c = 9.
a * (++b) % c
(a)
If int m = 5 and int n = 2 output the value of m after execution in the following expression:
n = m + m % n;
(a)
++ increases the value of a variable by 1
assignment operator
decrement operator
increment operator
sentinel
Which statement(s) are equivalent to i = i + 1?
i += 1
i++
i -= 1
i--
what is modulo operation used for ?
performs division
performs division and gives no remainder
performs division and gives remainder
does not perform division
arithmetic operators return a value. True or false?
true
false
Find the output of the following snippet.
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);
}
}
10
12
11
Compilation Error
Please write correct output in following space-
10
20
No Output
Error
Choose the logical operators
And
Less than
OR
Not Equal
What is the result of 13<=13 ?
True
False
Both true and false
None
The result of AND operator is always true, if both the conditions results are _____
True
False
What is the value in variable A?
A+=112
112
111
113
130
in Java every statement is end with _____?
Comma
Colon
Semicolon
Brace
Java is case sensitive language.
True
False
Write the java expression for the following
ax5+bx3+c
(a)
What will be the value of m if m = 8
m *= 8
(a)
Write the output of the following
( 4 > 7 ) || ( 7 < 15 )
true
false
The operator '==' checks for
Equal values
Greater values
lesser values
String values are always written in
Single quotes
without quotes
Double quotes
true && true
true
false
false == false
true
false
true != true
true
false
false || true
true
false
false && false
true
false
true || true
true
false
true == false
true
false
false != true
true
false
Types of Java Operators
logical
arithmetic
relational
all of above
Java expression
a<b
Types of operator for above expression is
Relational
logical
arithmetic
Evaluate this expression
a=3,b=4
!(a==0) && (b<5)
true
false
Which of the following statement is valid
int a+b=5;
double char =m;
int name;
name = 5;
IQ = 5;
int IQ;
Java expression
a&&b
Type of operator
relational
logical
arithmetic
Which one is correct?
public static main(Strings[] args) { }
public private static main(Strings[] args) { }
public static void main(Strings[] args) { }
public void static main(Strings[] args) { }
(=) sign means
equals and it is used for math problems in Java
assignment operator. It used to assign a value
