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);
}
}A. 5.640000000000001 5
B. 5.640000000000001 5.0
C. 5 5
D. 5 5.640000000000001
Select an option to see the answer and solution.
What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3A. Integer
B. Floating - point numbers
C. Boolean
D. None of the mentioned
Select an option to see the answer and solution.
Modulus operator, %, can be applied to which of these?
A. Integers
B. Floating - point numbers
C. Both Integers and floating - point numbers
D. None of the mentioned
Select an option to see the answer and solution.
Which of these is returned by "greater than", "less than" and "equal to" operators?
A. Integers
B. Floating - point numbers
C. Boolean
D. None of the mentioned
Select an option to see the answer and solution.
Which of the following is not a decision making statement?
A. if
B. if-else
C. switch
D. do-while
Select an option to see the answer and solution.
Which of the following is not a valid jump statement?
A. break
B. goto
C. continue
D. return
Select an option to see the answer and solution.
What would be the output of the following code snippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");Select an option to see the answer and solution.
Decrement operator, - -, decreases the value of variable by what number?
Select an option to see the answer and solution.
What will be the output of the following Java program?
class selection_statements
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}Select an option to see the answer and solution.
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);
}
}A. compile time error
B. runtime error
C. a=20 b=0 c=20 d=1
D. none of the mentioned
Select an option to see the answer and solution.
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);
}
}A. false false
B. true ture
C. true false
D. false true
Select an option to see the answer and solution.
Which of these selection statements test only for equality?
A. if
B. switch
C. if & switch
D. none of the mentioned
Select an option to see the answer and solution.
Which of these statements is correct?
A. true and false are numeric values 1 and 0
B. true and false are numeric values 0 and 1
C. true is any non zero value and false is 0
D. true and false are non numeric values
Select an option to see the answer and solution.
What is the output of relational operators?
A. Integer
B. Boolean
C. Characters
D. Double
Select an option to see the answer and solution.
What is the valid data type for variable "a" to print "Hello World"?
switch(a)
{
System.out.println("Hello World");
}A. int and float
B. byte and short
C. char and long
D. byte and char
Select an option to see the answer and solution.
Which of the following is not a valid flow control statement?
A. exit()
B. break
C. continue
D. return
Select an option to see the answer and solution.
The while loop repeats a set of code while the condition is not met?
Select an option to see the answer and solution.
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);
}
}Select an option to see the answer and solution.
What is true about a break?
A. Break stops the execution of entire program
B. Break halts the execution and forces the control out of the loop
C. Break forces the control out of the loop and starts the execution of next iteration
D. Break halts the execution of the loop for certain time frame
Select an option to see the answer and solution.
Which of these have highest precedence?
Select an option to see the answer and solution.