What will be the output of the following Java program?
class X
{
int a;
double b;
}
class Y extends X
{
int c;
}
class Output
{
public static void main(String args[])
{
X a = new X();
Y b = new Y();
Class obj;
obj = a.getClass();
System.out.print(obj.getName());
}
}Select an option to see the answer and solution.
Which of these is specified by a File object?
A. a file in disk
B. directory path
C. directory in disk
D. none of the mentioned
Select an option to see the answer and solution.
What will be the output of the following Java code?
class isinfinite_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isInfinite();
System.out.print(x);
}
}Select an option to see the answer and solution.
What will be the output of the following Java program?
class X
{
int a;
double b;
}
class Y extends X
{
int c;
}
class Output
{
public static void main(String args[])
{
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(obj.isLocalClass());
}
}Select an option to see the answer and solution.
What happens when a constructor is defined for an interface?
A. Compilation failure
B. Runtime Exception
C. The interface compiles successfully
D. The implementing class will throw exception
Select an option to see the answer and solution.
Which of the following is an incorrect statement about packages?
A. Package defines a namespace in which classes are stored
B. A package can contain other package within it
C. Java uses file system directories to store packages
D. A package can be renamed without renaming the directory in which the classes are stored
Select an option to see the answer and solution.
Which of these data type is returned by every method of OutputStream?
A. int
B. float
C. byte
D. none of the mentioned
Select an option to see the answer and solution.
What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.578123456789);
float x = i.floatValue();
System.out.print(x);
}
}A. 0
B. 257.0
C. 257.57812
D. 257.578123456789
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.io.*;
class Chararrayinput
{
public static void main(String[] args)
{
String obj = "abcdef";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
int i;
try
{
while ((i = input2.read()) != -1)
{
System.out.print((char)i);
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}A. abc
B. abcd
C. abcde
D. abcdef
Select an option to see the answer and solution.
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));
obj2.write(1);
}
}
System.out.print(obj2);
}
}
}A. AaBaCa
B. ABCaaa
C. AaaBaaCaa
D. AaBaaCaaa
Select an option to see the answer and solution.
Which of these is a wrapper for data type int?
A. Integer
B. Long
C. Byte
D. Double
Select an option to see the answer and solution.
What is the signature of Math.random() method?
A. public static double random()
B. public void double random()
C. public static int random()
D. public void int random()
Select an option to see the answer and solution.
Which of these class contains only floating point functions?
A. Math
B. Process
C. System
D. Object
Select an option to see the answer and solution.
Which of these classes can return more than one character to be returned to input stream?
A. BufferedReader
B. Bufferedwriter
C. PushbachReader
D. CharArrayReader
Select an option to see the answer and solution.
Which of these classes is used for input and output operation when working with bytes?
A. InputStream
B. Reader
C. Writer
D. All of the mentioned
Select an option to see the answer and solution.
Standard output variable 'out' is defined in which class?
A. Void
B. Process
C. Runtime
D. System
Select an option to see the answer and solution.
Which of these class produce objects with respect to geographical locations?
A. TimeZone
B. Locale
C. Date
D. SimpleTimeZone
Select an option to see the answer and solution.
What will be the output of the following Java code?
class binary
{
public static void main(String args[])
{
int num = 17;
System.out.print(Integer.toBinaryString(num));
}
}A. 1001
B. 10011
C. 11011
D. 10001
Select an option to see the answer and solution.
Which of these classes encapsulate runtime state of an object?
A. Class
B. System
C. Runtime
D. Cache
Select an option to see the answer and solution.
Which of the following is method of System class is used to find how long a program takes to execute?
A. currenttime()
B. currentTime()
C. currentTimeMillis()
D. currenttimeMillis()
Select an option to see the answer and solution.