Home

Java Programming MCQ Question with Answer

Java Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download Java Programming MCQ Question Answer PDF

Question No : 36
Which are the valid ways to create DataInputStream streams?

new DataInputStream(new File("in.dat"));
new DataInputStream(new FileInputStream("in.dat"));
new DataInputStream("in.dat");
new DataInputStream("in.data","r");

Question No : 37
Which exception is thrown by the read() method of InputStream class?

IOException
FileNotFoundException
ReadException
None of the above

Question No : 38
In the code below, what data types the variable x can have?

byte b1 = 5;
byte b2 = 10;
x = b1 * b2;
int short

Question No : 39
If you want to assign a value of 99 to the variable year, then which of the following lines can be used within an <applet> tags?

number=getParameter(99)
<number==99>
<param = radius value ==99>

Question No : 40
What is java -g used for?

Using the jdb tool
Executing a class with optimization turned off
To provided information about deprecated methods
Non of the above

Question No : 41
With javadoc, which of the following denotes a javadoc comment?

//#
/*
/**
//**

Question No : 42
Give file is a file object, which of the following are legal statements to create a new file.

file.create();
FileOutputStream fos=new FileOutputStream(file);
FileInputStream fis=new FileInputStream(file);
all of the above