Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?(a) transient(b) volatile(c) global(d) No modifier is neededI got this question in final exam.Enquiry is from Applets Fundamentals in division I/O & Applets of Java

Answer»

The correct option is (B) volatile

Easiest explanation: The volatile modifier TELLS the compiler that the variable modified by volatile can be changed unexpectedly by other part of the PROGRAM. Specially used in situations INVOLVING MULTITHREADING.

2.

Which of these methods is a part of Abstract Window Toolkit (AWT)?(a) display()(b) paint()(c) drawString()(d) transient()This question was addressed to me during an interview.Origin of the question is Applets Fundamentals topic in portion I/O & Applets of Java

Answer»

The CORRECT option is (b) PAINT()

To EXPLAIN I would say: paint() is an abstract METHOD defined in AWT.

3.

Which of these methods can be used to output a string in an applet?(a) display()(b) print()(c) drawString()(d) transient()This question was addressed to me during an interview.I would like to ask this question from Applets Fundamentals topic in section I/O & Applets of Java

Answer»

The correct choice is (c) drawString()

Explanation: drawString() method is defined in GRAPHICS CLASS, it is used to OUTPUT a string in an APPLET.

4.

Which of these functions is called to display the output of an applet?(a) display()(b) paint()(c) displayApplet()(d) PrintApplet()This question was addressed to me in a job interview.I want to ask this question from Applets Fundamentals topic in section I/O & Applets of Java

Answer»

The CORRECT answer is (b) PAINT()

Easiest explanation: Whenever the applet requires to redraw its OUTPUT, it is DONE by using method paint().

5.

Which of these values is returned by read() method is end of file (EOF) is encountered?(a) 0(b) 1(c) -1(d) NullThis question was addressed to me by my college director while I was bunking the class.Question is taken from Reading & Writing Files in portion I/O & Applets of Java

Answer»

Right option is (C) -1

The best explanation: Each time read() is called, it reads a single byte from the FILE and returns the byte as an INTEGER value. read() returns -1 when the END of the file is encountered.

6.

Which of these exception is thrown by close() and read() methods?(a) IOException(b) FileException(c) FileNotFoundException(d) FileInputOutputExceptionThis question was posed to me in class test.I'm obligated to ask this question of Reading & Writing Files in portion I/O & Applets of Java

Answer»

Correct choice is (a) IOEXCEPTION

For explanation: Both CLOSE() and READ() method throw IOException.

7.

Which of these methods are used to read in from file?(a) get()(b) read()(c) scan()(d) readFileInput()This question was posed to me during an online exam.My question is taken from Reading & Writing Files in chapter I/O & Applets of Java

Answer»

Right choice is (B) read()

To explain: Each TIME read() is called, it READS a single byte from the file and returns the byte as an integer value. read() returns -1 when the END of the file is encountered.

8.

Which of these exception is thrown in cases when the file specified for writing is not found?(a) IOException(b) FileException(c) FileNotFoundException(d) FileInputExceptionI got this question in exam.My enquiry is from Reading & Writing Files topic in portion I/O & Applets of Java

Answer» RIGHT OPTION is (C) FileNotFoundException

Explanation: In cases when the file specified is not found, then FileNotFoundException is thrown by JAVA run-time system, earlier versions of java used to throw IOException but after Java 2.0 they throw FileNotFoundException.
9.

Which of these class contains the methods used to write in a file?(a) FileStream(b) FileInputStream(c) BUfferedOutputStream(d) FileBufferStreamThe question was posed to me in an interview for job.The origin of the question is Reading & Writing Files in division I/O & Applets of Java

Answer» CORRECT ANSWER is (B) FileInputStream

The EXPLANATION is: NONE.
10.

Which of these class is used to read characters and strings in Java from console?(a) BufferedReader(b) StringReader(c) BufferedStreamReader(d) InputStreamReaderThis question was posed to me in a national level competition.I want to ask this question from Reading Console Input in division I/O & Applets of Java

Answer»

The CORRECT ANSWER is (a) BufferedReader

To ELABORATE: NONE.

11.

Which of these is used to read a string from the input stream?(a) get()(b) getLine()(c) read()(d) readLine()The question was asked in an interview.This interesting question is from Reading Console Input in chapter I/O & Applets of Java

Answer» RIGHT OPTION is (c) read()

To EXPLAIN I would say: None.
12.

Which exception is thrown by read() method?(a) IOException(b) InterruptedException(c) SystemException(d) SystemInputExceptionI had been asked this question in quiz.Query is from Reading Console Input topic in section I/O & Applets of Java

Answer»

Right choice is (a) IOException

Easiest EXPLANATION: read METHOD THROWS IOException.

13.

Which of these classes are used by Byte streams for input and output operation?(a) InputStream(b) InputOutputStream(c) Reader(d) All of the mentionedThis question was addressed to me in unit test.The above asked question is from Input & Output Basics topic in division I/O & Applets of Java

Answer» CORRECT answer is (a) InputStream

To explain I WOULD say: Byte STREAM uses InputStream and OUTPUTSTREAM classes for input and output operation.
14.

Which of these classes are used by character streams for input and output operations?(a) InputStream(b) Writer(c) ReadStream(d) InputOutputStreamI have been asked this question by my school teacher while I was bunking the class.Question is from Input & Output Basics in chapter I/O & Applets of Java

Answer»

The correct choice is (b) WRITER

For explanation: Character STREAMS uses Writer and Reader CLASSES for input & output operations.

15.

Which of these is a type of stream in Java?(a) Integer stream(b) Short stream(c) Byte stream(d) Long streamThis question was posed to me during an interview for a job.Origin of the question is Input & Output Basics topic in section I/O & Applets of Java

Answer» RIGHT choice is (c) Byte stream

To explain I would SAY: JAVA defines only TWO types of STREAMS – Byte stream and character stream.
16.

Which of these is used to perform all input & output operations in Java?(a) streams(b) Variables(c) classes(d) MethodsThe question was posed to me in exam.This interesting question is from Input & Output Basics in chapter I/O & Applets of Java

Answer»

The CORRECT choice is (a) STREAMS

To elaborate: LIKE in any other language, streams are used for INPUT and output OPERATIONS.

17.

What does AWT stands for?(a) All Window Tools(b) All Writing Tools(c) Abstract Window Toolkit(d) Abstract Writing ToolkitThis question was posed to me during an online exam.My question is from Input & Output Basics topic in chapter I/O & Applets of Java

Answer»

The CORRECT ANSWER is (c) Abstract Window Toolkit

The BEST I can explain: AWT stands for Abstract Window Toolkit, it is USED by applets to interact with the user.