Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.


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);
}
}
  1.    0
  2.    3
  3.    3.0
  4.    4
 Discuss Question
Answer: Option D. -> 4

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


Question 2.


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);
}
}
  1.    0
  2.    3
  3.    3.0
  4.    4
 Discuss Question
Answer: Option D. -> 4

ciel(double X) returns the smallest whole number greater than or equal to variable x.
Output:
$ javac Output.java
$ java Output
4


Question 3.


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);
}
}
  1.    0
  2.    3
  3.    3.0
  4.    3.1
 Discuss Question
Answer: Option B. -> 3

None.
Output:
$ javac Output.java
$ java Output
3


Question 4.


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();
}
}
  1.    1 2 0 0
  2.    1 2 1 2
  3.    0 0 0 0
  4.    System Dependent
 Discuss Question
Answer: Option B. -> 1 2 1 2

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


Question 5.

Which of function return absolute value of a variable?


  1.    abs()
  2.    absolute()
  3.    absolutevariable()
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> abs()

abs() returns the absolute value of a variable.


Question 6.

Which of these class contains only floating point functions?


  1.    Math
  2.    Process
  3.    System
  4.    Object
 Discuss Question
Answer: Option A. -> Math

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.


Question 7.

Which of these method return a smallest whole number greater than or 

equal to variable X?


  1.    double ciel(double X)
  2.    double floor(double X)
  3.    double max(double X)
  4.    double min(double X)
 Discuss Question
Answer: Option A. -> double ciel(double X)

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


Question 8.

Which of these method return a largest whole number less than or equal to 

variable X?


  1.    double ciel(double X)
  2.    double floor(double X)
  3.    double max(double X)
  4.    double min(double X)
 Discuss Question
Answer: Option B. -> double floor(double X)

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


Question 9.

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


  1.    max()
  2.    min()
  3.    abs()
  4.    rint()
 Discuss Question
Answer: Option D. -> rint()

rint() rounds up a variable to nearest integer.


Question 10.

Which of these class provides various types of rounding functions?


  1.    Math
  2.    Process
  3.    System
  4.    Object
 Discuss Question
Answer: Option A. -> Math

None.


Latest Videos

Latest Test Papers