This set of MCQ(multiple choice questions) focuses on the Programming in Java Week 7 Solutions.
Course layout (Answers Link)
Answers COMING SOON! Kindly Wait!
Week 1: Overview of Object-Oriented Programming and Java
Programming Assignment
Week 2: Java Programming Elements
Programming Assignment
Week 3: Input-Output Handling in Java
Programming Assignment
Week 4: Encapsulation
Programming Assignment
Week 5: Inheritance
Programming Assignment
Week 6: Exception Handling
Programming Assignment
Week 7: Multithreaded Programming
Programming Assignment
Week 8: Java Applets and Servlets
Programming Assignment
Week 9: Java Swing and Abstract Windowing Toolkit
Programming Assignment
Week 10: Networking with Java
Week 11: Java Object Database Connectivity
Week 12: Interface and Packages for Software Development
NOTE: You can check your answer immediately by clicking show answer button. Programming in Java Week 7 Solutions” contains 10 questions.
Now, start attempting the quiz.
Programming in Java Week 7 Solutions
Q1. Consider the following program.
What will be the output of the above program is executed?
a) It will give compile-time error
b) 102
c) 42
d) f
Answer: d) f
Q2. 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 {}
Answer: c)
Q3. Which of the followng is NOT a Standard Stream?
a) System.in
b) System.out
c) System.err
d) System.console
Answer: d) System.console
Q4. Which of the following method(s) not included in OutputStream class?
a) close()
b) write()
c) skip()
d) flush()
Answer: c) skip()
Q5. Which of the following method 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)
Answer: b) readLine()
Q6. Consider the following program.
What is the output of the above code?
a) java/course/july/2023
b) java/course/july/
c) java/course/
d) 2023
Answer: a) java/course/july/2023
Q7. Which of the following is/are interface(s) in java.io package?
a) FileWriter
b) FileFilter
c) ObjectOutput
d) DataOutput
Answer: b), c), d)
Q8. Fill in the blanks.
The class DataInputStream extends _________ and implements the interface _____________.
a) FileInputStream, FileInput
b) FilterInputStream, DataInput
c) FilterInputStream, FileInput
d) FileInputStream, DataInput
Answer: b) FilterInputStream, DataInput
Q9. Which of the following method(s) not included in InputStream class?
a) available()
b) reset()
c) read()
d) flush()
Answer: d) flush()
Q10. Which of the following package 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
Answer: b) java.io
Programming in Java Week 7 Solutions
Q1. Which of these is a type of IO stream in Java?
a) Integer stream
b) Short stream
c) Byte stream
d) Character stream
Answer: c), d)
Q2. Which of the following is a class in java.io package?
a) FileReader
b) ObjectInput
c) ObjectOutput
d) DataInput
Answer: a)
Q3. What will be the output if the above program is executed?
a) It will give compile-time error
b) B
c) 66
d) r
Answer: d)
Q4. What is the output of the above code?
a) java/program/2023
b) java/programm/
c) java
d) 2023
Answer: d)
Q5. 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(bute[] b) throws IOException{}
c) public void read(byte[] b) throws IOException{}
d) public int read(int b) throws IOException{}
Answer: b)
Q6. How many standard streams Java can support?
a) 2
b) 3
c) 4
d) 1
Answer: b)
Q7. Which of the following stream is different from others?
a) System.in
b) System.out
c) PrintStream
d) FileOutputStream
Answer: a)
Q8. Which of the following is used to read a string from the input stream?
a) get()
b) readLine()
c) getLine()
d) read()
Answer: d)
Q9. Which of the following class(es) can be use for handling files in Java?
a) java.files
b) java.io.File
c) java.io
d) java.Filehandling
Answer: b)
Q10. Which of the following statement(s) is/are true?
a) The default delimiters for a Scanner object are the white space characters
b) The Scanner class has instance methods for reading each of the Java primitive types except char
c) The Scanner methods do not throw any checked exceptions
d) The Scanner class can be found in the java.util package
Answer: a), b), d)
Previous – Programming in Java Week 7 Solutions
Q1. Which of these is method for testing whether the specified element is a file or a directory?
a) IsFile()
b) isFile()
c) Isfile()
d) isfile()
Answer: b) isFile()
Q2. Which of the following is/are NOT Standard Stream(s)?
a) System.in
b) System.out
c) System.err
d) System.console
Answer: d) System.console
Q3. What will be the output of the Java code?
a) NPTEL
b) NPTEL/JULY/2022
c) /NPTEL/JULY/2022
d) 2022
Answer: d) 2022
Q4. What will be the output if the above program is executed?
a) It will give compile-time error
b) It will give run-time error
c) j
d) 106
Answer: d) 106
Q5. Which method is used to write a byte to the current output stream?
a) public void write(int b) throws IOException
b) public void write(byte[] b) throws IOException
c) public void flush() throws IOException
d) public void close() throws IOException
Answer: a) public void write(int b) throws IOException
Q6. Which method of RandomAccessFile class reads a line from the file and returns it as a String?
a) WriteInt()
b) readLine()
c) readInt()
d) WriteDouble()
Answer: b) readLine()
Q7. Which of these class is not a member class of java.io package?
a) File
b) PrintStream
c) StringReader
d) Stream
Answer: d) Stream
Q8. Which of the following is/are interface(s) of java.io package?
a) FileReader
b) FileWriter
c) DataOutput
d) DataInput
Answer: c), d)
Q9. In which Java APIs the classes for handling all IO-streams are defined?
a) java.lang
b) java.util
c) java.io
d) java.awt
Answer: c) java.io
Q10. If the program is executed, then what will be the output from the execution?
a) length: 6
b) length: 5
c) length: 0
d) length: 1
Answer: b) length: 5
Previous Course – Week 7 Quiz Solutions
Q1. Which of the following streams contains the classes which can work on character stream?
a) InputStream
b) OutputStream
c) FileReader
d) FileWriter
Answer: c), d)
Q2. In which Java APIs the classes for handling all IO-streams are defined?
a) java.lang
b) java.util
c) java.io
d) java.awt
Answer: c) java.io
Q3. What will be the output if the above program is executed?
a) It will give compile-time error
b) It will give run-time error
c) j
d) 106
Answer: c) j
Q4. Which of the following is the correct output for the ‘try’ portion of the code?
a) Prints the number of bytes in the file
b) Prints the number of characters in the file
c) Prints ‘true’, if the file is present; else prints ‘false’
d) Prints nothing, as an exception will be caught
Answer: b) Prints the number of characters in the file
Q5. Which methods is used to write an array of byte to the current output stream?
a) public void write(int b)throws IOException
b) public void write(byte[] b)throws IOException
c) public void flush()throws IOException
d) public void close()throws IOException
Answer: b) public void write(byte[] b)throws IOException
Q6. Which of the following is/are Standard Stream(s)?
a) System.in
b) System.out
c) System.err
d) System.console
Answer: a), b), c)
Q7. Which of the following method in java.io package help in clearing the contents of the buffer?
a) flush()
b) clear()
c) append()
d) exit()
Answer: a) flush()
Q8. Which method of RandomAcessFile class reads a line from the file and returns it as a String?
a) WriteInt()
b) readLine()
c) readInt()
d) WriteDouble()
Answer: b) readLine()
Q9. Which of the following is/are interface(s) of java.io package?
a) FileReader
b) ObjectInput
c) ObjectOutput
d) DataInput
Answer: b), c), d)
Q10. Which of the following statement(s) is/are true?
a) DataStreams detects an end-of-file condition by using EOFException, instead of testing for an invalid return value
b) DataStreams uses floating point numbers to represent monetary values
c) Data streams support I/O of primitive data types
d) Object streams support I/O of objects
Answer: a), b), c), d)
>> Next- Programming in Java Week 6 Assignment Solutions
>> Next- Programming in Java Week 8 Assignment Solutions
DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.
For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.