514). Which of these class provides various types of rounding functions?
[A]Math
[B]Process
[C]System
[D]Object
Show Answer
Correct Answer: Math
Notes:
Answer: a
Explanation: None.
515). Which of these methods return a smallest whole number greater than or equal to variable X?
[A]double ceil(double X)
[B]double floor(double X)
[C]double max(double X)
[D]double min(double X)
Show Answer
Correct Answer: double ceil(double X)
Notes:
Answer: a
Explanation: ceil(double X) returns the smallest whole number greater than or equal to variable X.
516). Which of these method returns a largest whole number less than or equal to variable X?
[A] double ceil(double X)
[B]double floor(double X)
[C]double max(double X)
[D]double min(double X)
Show Answer
Correct Answer: double floor(double X)
Notes:
Answer: b
Explanation: double floor(double X) returns a largest whole number less than or equal to variable X.
517). Which of function return absolute value of a variable?
[A]abs()
[B]absolute()
[C]absolutevariable()
[D]none of the mentioned
Show Answer
Correct Answer: abs()
Notes:
Answer: a
Explanation: abs() returns the absolute value of a variable.
518). What will be the output of the following Java code?
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
Show Answer
Correct Answer: 1 2 1 2
Notes:
Answer: b
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
519). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.abs(x);
System.out.print(y);
}
}
Show Answer
Correct Answer: 3
Notes:
Answer: b
Explanation: None.
Output:
$ javac Output.java
$ java Output
3
520). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.ceil(x);
System.out.print(y);
}
}
Show Answer
Correct Answer: 4
Notes:
Answer: d
Explanation: ciel(double X) returns the smallest whole number greater than or equal to variable x.
Output:
$ javac Output.java
$ java Output
4
521). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.floor(x);
System.out.print(y);
}
}
Show Answer
Correct Answer: 3
Notes:
Answer: b
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