What will be the output of the following Java code? class Output ...
View Question
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();
}
}
What will be the output of the following Java code? class A ...
View QuestionWhich of function return absolute value of a variable?
a) abs() b) absolute() c) absolutevariable() d) none of the mentioned Answer: a Explanation: abs() ...
View QuestionWhich 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 ...
View QuestionWhich 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) Answer: ...
View QuestionWhich of these class provides various types of rounding functions?
a) Math b) Process c) ...
View Question
What will be the output of the following Java program?
class exception_handling
{
public static void main(String args[])
{
try
{
int a = args.length;
int b = 10 / a;
System.out.print(a);
try
{
if (a == 1)
a = a / a – a;
if (a == 2)
{
int c = {1};
c[8] = 9;
}
}
catch (ArrayIndexOutOfBoundException e)
{
System.out.println(“TypeA”);
}
catch (ArithmeticException e)
{
System.out.println(“TypeB”);
}
}
}
What will be the output of the following Java program? class exception_handling ...
View Question
What will be the output of the following Java program?
class exception_handling
{
public static void main(String args[])
{
try
{
int a = 1;
int b = 10 / a;
try
{
if (a == 1)
a = a / a – a;
if (a == 2)
{
int c[] = {1};
c[8] = 9;
}
finally
{
System.out.print(“A”);
}
}
catch (NullPointerException e)
{
System.out.println(“B”);
}
}
}
What will be the output of the following Java program? class exception_handling ...
View Question
What will be the output of the following Java program?
class exception_handling
{
static void throwexception() throws ArithmeticException
{
System.out.print(“0”);
throw new ArithmeticException (“Exception”);
}
public static void main(String args[])
{
try
{
throwexception();
}
catch (ArithmeticException e)
{
System.out.println(“A”);
}
}
}
What will be the output of the following Java program? class exception_handling ...
View Question
What will be the output of the following Java program?
class exception_handling
{
public static void main(String args[])
{
try
{
int a[] = {1, 2,3 , 4, 5};
for (int i = 0; i < 5; ++i)
System.out.print(a[i]);
int x = 1/0;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print(“A”);
}
catch(ArithmeticException e)
{
System.out.print(“B”);
}
}
}
What will be the output of the following Java program? class exception_handling ...
View Question