Java MCQ Questions and Answers

Practice Mode
Showing 10 of 22 questions
Q11
Which of the following are true about the Error and Exception classes?
  • A Both classes extend Throwable.
  • B The Error class is final and the Exception class is not.
  • C The Exception class is final and the Error is not.
  • D Both classes implement Throwable.
Answer: Option A
Q12
Which of the following are true?
  • A The Void class extends the Class class.
  • B The Float class extends the Double class.
  • C The System class extends the Runtime class.
  • D The Integer class extends the Number class.
Answer: Option D
Q13
Which of the following will output -4.0
  • A System.out.println(Math.floor(-4.7));
  • B System.out.println(Math.round(-4.7));
  • C System.out.println(Math.ceil(-4.7));
  • D System.out.println(Math.Min(-4.7));
Answer: Option C
Q14
Which of the following are valid statements
  • A public class MyCalc extends Math
  • B Math.max(s);
  • C Math.round(9.99,1);
  • D None of the above.
Answer: Option D
Q15
) What will happen if you attempt to compile and run the following code? Integer ten=new Integer(10); Long nine=new Long (9); System.out.println(ten + nine); int i=1; System.out.println(i + ten);
  • A 19 followed by 20
  • B 19 followed by 11
  • C Error: Can't convert java lang Integer
  • D 10 followed by 1
Answer: Option A
Q16
Which of the following statements are true?
  • A UTF characters are all 8-bits.
  • B UTF characters are all 16-bits.
  • C UTF characters are all 24-bits.
  • D Unicode characters are all 16-bits.
Answer: Option D
Q17
Which of the following statements are true? a)When you construct an instance of File, if you do not use the file naming semantics of the local machine, the constructor will throw an IOException. b)When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created. c)When an instance of File is garbage collected, the corresponding file on the local file system is deleted. d)None of the above
  • A a&b
  • B b,c&d
  • C a,c&b
  • D b,c&d
Answer: Option C
Q18
Which of the following are true? a)The InputStream and OutputStream classes are byte-oriented. b)The ObjectInputStream and ObjectOutputStream do not support serialized object input and output. c)The Reader and Writer classes are character-oriented. d)The Reader and Writer classes are the preferred solution to serialized object output.
  • A a&b
  • B c&b
  • C d&c
  • D a&c
Answer: Option D
Q19
Which of the following are true about I/O filters? a)Filters are supported on input, but not on output. b)Filters are supported by the InputStream/OutputStream class hierarchy, but not by the Reader/Writer class hierarchy. c)Filters read from one stream and write to another. d)A filter may alter data that is read from one stream and written to another.
  • A a&b
  • B c&d
  • C c&a
  • D b&c
Answer: Option B
Q20
Which of the following are true? a)Any Unicode character is represented using 16-bits. b)7-bits are needed to represent any ASCII character. c)UTF-8 characters are represented using only 8-bits. d)UTF-16 characters are represented using only 16-bits.
  • A a&c
  • B b&c
  • C a&b
  • D d&a
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test