0% found this document useful (0 votes)
25 views

Week-07-Assignment Update

Java programming 3

Uploaded by

smeyyarul599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Week-07-Assignment Update

Java programming 3

Uploaded by

smeyyarul599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

NPTEL Online Certification Courses

Indian Institute of Technology Kharagpur

PROGRAMMING IN JAVA
Assignment7
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 × 1 = 10
______________________________________________________________________________

QUESTION 1:
Consider the following program.

import java.io.*;
public class Question {
public static void main(String[] args)
{
try {
PrintWriter writer = new PrintWriter(System.out);
writer.write('4'+ '2');
writer.close();
}
catch (Exception e) {
System.out.println(e);
}
}
}

What will be the output if the above program is executed?


a. It will give a compile-time error.
b. 102
c. 42
d. f

Correct Answer: d

Detailed Solution:

The expression '4'+'2' add 52 with 50(i.e, Ascii value of 4 and 2)=102 and
print the corresponding char, in this case, f.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 2:
Which method is used to write an array of byte to the current output stream?

a. public void write(int b)throws IOException{{


b. public void flush(byte[ ] b)throws IOException{}
c. public void write(byte[ ] b)throws IOException{}
d. public int write(int b)throws IOException{}

Correct Answer: c

Detailed Solution:

public void write(byte[ ] b)throws IOException{} is used to write an array of byte to the current
output stream.

_____________________________________________________________

QUESTION 3:
Which of the following is NOT a Standard Stream?

a. System.in
b. System.out
c. System.err
d. System.console

Correct Answer: d

Detailed Solution:
The Java platform supports three Standard Streams: Standard Input, accessed
through System.in; Standard Output, accessed through System.out; and Standard Error, accessed
through System.err.
______________________________________________________________________________

QUESTION 4:
Which of the following method(s) is not included in the OutputStream class?

a. close( )
b. write( )
c. skip( )
d. flush( )

Correct Answer: c
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Detailed Solution:

skip( ) is not a valid method in the OutputStream class.

______________________________________________________________________________

QUESTION 5:
Which of the following methods of the BufferedReader class is used for reading lines of text
from the console, the file, or other input streams?

a. read( )
b. readLine( )
c. readByte( )
d. read(byte [ ] b)

Correct Answer: b

Detailed Solution:

readLine( ) method of the BufferedReader class is used for reading lines of text from the console,
the file, or other input streams.
__________________________________________________________________________

QUESTION 6:
Consider the following program.

import java.io.*;
public class files
{
public static void main(String args[])
{
File obj = new File("java/course/july/2023");
System.out.print(obj.getPath());
}
}

What is the output of the above code?

a. java/course/july/2023
b. java/course/july/
c. java/course/
d. 2023
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Correct Answer: a
Detailed Solution:
Test by run.
______________________________________________________________________________
QUESTION 7:
Which of the following is/are interface(s) in the java.io package?

a. FileWriter
b. FileFilter
c. ObjectOutput
d. DataOutput

Correct Answer: b, c, d

Detailed Solution:

FileWriter is a class in the java.io package. All others are interfaces.


______________________________________________________________________________

QUESTION 8:
Fill in the blanks.
The class DataInputStream extends ____________ and implements the interface
_____________.

a. FileInputStream , FileInput
b. FilterInputStream , DataInput
c. FilterInputStream , FileInput
d. FileInputStream , DataInput

Correct Answer: b

Detailed Solution:

public class DataInputStream extends FilterInputStream implements DataInput.

______________________________________________________________________________
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 9:
Which of the following method(s) is not included in InputStream class?

a. available( )
b. reset( )
c. read( )
d. flush( )

Correct Answer: d

Detailed Solution:

flush( ) is not a valid method in the InputStream class.

__________________________________________________________________

QUESTION 10:
Which of the following package(s) contains a large number of stream classes that provide
capabilities for processing all types of data?

a. java.awt.
b. java.io
c. java.net
d. java.util

Correct Answer: b

Detailed Solution:

java.io contains a large number of stream classes that provide capabilities for processing all
types of data.

You might also like