a) Math

b) Process

c) System

d) Object

View Answer

Explanation: None.

2. Which of these method return a smallest whole number greater than or equal to variable X?

a) double ciel(double X)

b) double floor(double X)

c) double max(double X)

d) double min(double X)

View Answer

Explanation: ciel(double X) returns the smallest whole number greater than or equal to variable X.

3. Which of these method return a largest whole number less than or equal to variable X?

a) double ciel(double X)

b) double floor(double X)

c) double max(double X)

d) double min(double X)

View Answer

Explanation: double floor(double X) returns a largest whole number less than or equal to variable X.

4. Which of these method is a rounding function of Math class?

a) max()

b) min()

c) abs()

d) rint()

View Answer

Explanation: rint() rounds up a variable to nearest integer.

5. Which of these class contains only floating point functions?

a) Math

b) Process

c) System

d) Object

View Answer

Explanation: Math class contains all the floating point functions that are used for geometry, trigonometry, as well as several general purpose methods. Example : sin(), cos(), exp(), sqrt() etc.

6. Which of function return absolute value of a variable?

a) abs()

b) absolute()

c) absolutevariable()

d) None of the mentioned

View Answer

Explanation: abs() returns the absolute value of a variable.

7. What is the output of this program?

class A {

int x;

int y;

void display() {

System.out.print(x + " " + y);

`}`

`}`

class Output {

public static void main(String args[]) {

A obj1 = new A();

A obj2 = new A();

obj1.x = 1;

obj1.y = 2;

obj2 = obj1.clone();

obj1.display();

obj2.display();

`}`

`}`

a) 1 2 0 0

b) 1 2 1 2

c) 0 0 0 0

d) System Dependent

View Answer

Explanation: clone() method of object class is used to generate duplicate copy of the object on which it is called. Copy of obj1 is generated and stored in obj2.

Output:

$ javac Output.java

$ java Output

1 2 1 2

8. What is the output of this program?

class Output {

public static void main(String args[]) {

double x = 3.14;

int y = (int) Math.abs(x);

System.out.print(y);

`}`

`}`

a) 0

b) 3

c) 3.0

d) 3.1

View Answer

Explanation: None.

Output:

$ javac Output.java

$ java Output

3

9. What is the output of this program?

class Output {

public static void main(String args[]) {

double x = 3.14;

int y = (int) Math.ceil(x);

System.out.print(y);

`}`

`}`

a) 0

b) 3

c) 3.0

d) 4

View Answer

Explanation: ciel(double X) returns the smallest whole number greater than or equal to variable x.

Output:

$ javac Output.java

$ java Output

4

10. What is the output of this program?

class Output {

public static void main(String args[]) {

double x = 3.14;

int y = (int) Math.floor(x);

System.out.print(y);

`}`

`}`

a) 0

b) 3

c) 3.0

d) 4

View Answer

Explanation: double floor(double X) returns a largest whole number less than or equal to variable X. Here the smallest whole number less than 3.14 is 3.

Output:

$ javac Output.java

$ java Output

3

**Sanfoundry Global Education & Learning Series Java Programming Language.**

To practice all features of Java programming language, __here is complete set on 1000+ Multiple Choice Questions and Answers on Java__.