NPTEL Programming in Java Week 7 Assignment Answers 2024

Sanket
By Sanket

NPTEL Programming in Java Week 7 Assignment Answers 2024

1. Which of these exception is thrown in cases when the file specified for writing is not found?

a. IOException
b. FileException
c. FileNotFoundException
d. FileInputException

Answer :- For Answers Click Here 

2. Which of these values is returned by read() method is end of file (EOF) is encountered?

a. 0
b. 1
c. -1
d. Null

Answer :- For Answers Click Here 

3. What will be the output of the following Java program?

image 22

a. abc
b. abcd
c. abcde
d. abcdef

Answer :- For Answers Click Here 

4. What is the purpose of a ByteArrayOutputStream in Java?

a. To write binary data to an output stream
b. To read binary data from an input stream
c. To convert characters to bytes
d. To store binary data in memory

Answer :- 

5. Which method is used to read b length bytes from the input stream into an array?

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

Answer :- 

6. Which method is used to create a directory with fileattributes?

a. Path.create()
b. Path.createDirectory()
c. Files.createDirectory(path, fileAttributes)
d. Files.create(fileAttributes)

Answer :- For Answers Click Here 

7. What will be the output of the following Java program?

image 23

a. 20
b. 100
c. 1000
d. 2

Answer :- 

8. Which class is used to write primitive data types to an output stream in Java?

a. DataOutputStream
b. ObjectOutputStream
c. OutputStream
d. PrintWriter

Answer :- 

9. What will be the output of the following code?

image 24

a. It will give compile-time error
b. It will give run-time error
c. j
d. 106

Answer :- 

10. What will be the output of the following code.
file.txt contain “This is Programming in Java online course.” (without quotes)

image 25

a. 42
b. 35
c. 7
d. 0

Answer :- For Answers Click Here 
Share This Article
Leave a comment