91. Which of these values are returns under the case of normal termination of a program?
92. 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");
}
}
}
Note: Execution command line: $ java exception_handling one two
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");
}
}
}
Note: Execution command line: $ java exception_handling one two
93. What will be the output of the following Java program?
interface calculate
{
void cal(int item);
}
class display implements calculate
{
int x;
public void cal(int item)
{
x = item * item;
}
}
class interfaces
{
public static void main(String args[])
{
display arr = new display;
arr.x = 0;
arr.cal(2);
System.out.print(arr.x);
}
}
interface calculate
{
void cal(int item);
}
class display implements calculate
{
int x;
public void cal(int item)
{
x = item * item;
}
}
class interfaces
{
public static void main(String args[])
{
display arr = new display;
arr.x = 0;
arr.cal(2);
System.out.print(arr.x);
}
}
94. What does an interface contain?
95. Math.random() guarantees uniqueness?
96. What will be the output of the following Java program?
package pkg;
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello World");
s1.insert(6 , "Good ");
System.out.println(s1);
}
}
Note : Output.class file is not in directory pkg.
package pkg;
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello World");
s1.insert(6 , "Good ");
System.out.println(s1);
}
}
Note : Output.class file is not in directory pkg.
97. What will be the output of the following Java program?
import java.io.*;
public class filesinputoutput
{
public static void main(String[] args)
{
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i)
{
int c;
while ((c = obj1.read()) != -1)
{
if (i == 0)
{
System.out.print(Character.toUpperCase((char)c));
}
}
}
}
}
import java.io.*;
public class filesinputoutput
{
public static void main(String[] args)
{
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i)
{
int c;
while ((c = obj1.read()) != -1)
{
if (i == 0)
{
System.out.print(Character.toUpperCase((char)c));
}
}
}
}
}
98. How to assign values to variable using property?
99. Which of these methods return string equivalent of Boolean object?
100. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
double x = 102;
double y = 5;
double z = Math.IEEEremainder(x, y);
System.out.print(z);}
}
}
class Output
{
public static void main(String args[])
{
double x = 102;
double y = 5;
double z = Math.IEEEremainder(x, y);
System.out.print(z);}
}
}
Read More Section(Interfaces and Abstract Classes)
Each Section contains maximum 100 MCQs question on Interfaces and Abstract Classes. To get more questions visit other sections.