Home

Java Programming MCQ Question with Answer

Java Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download Java Programming MCQ Question Answer PDF

Question No : 1
Which of the following will produce a value of 22 if x=22.9:

Ceil(x)
Round(x)
Rint(x)
Abs(x)

Question No : 2
If m and n are int type variables, what will be the result of the expression
'm % n' when m = -14 and n = -3?

4
2
-2
-4

Question No : 3
Consider the following statements:

int x = 10, y = 15; 
x = ((x < y) ? (y + x) : (y - x);

What will be the value of x after executing these statements?

25
15
5
Error can't be executed.

Question No : 4
Which of the following will produce a value of 10 if x = 9.7?

floor(x)
abs(x)
rint(x)
round(x)

Question No : 5
Which of the following control expressions are valid for an if statement?

an integer expression
a Boolean expression
either A or B
Neither A or B

Question No : 6
Consider the following class definition.
Class Student extends String
{
}
What happens when we try to compile this class?

Will not compile because class body is not defined
Will not compile because class is not declared public
Will compile successfully.
Will not compile because String is abstract

Question No : 7
What is wrong in the following class definitions? 

abstract class print { 
abstract show();
}
class Display extends print {
}

Nothing is wrong
Wrong Method show() should have a return type
Wrong Methods show() is not implemented in Display
Wrong Display does not contain any members.