Multithreaded Programming MCQs | PROGRAMMING IN JAVA Assignment 7 | NPTEL

PROGRAMMING IN JAVA Assignment 7 | NPTEL | Answer with Explanation | Multithreaded Programming MCQs

Test Your Java Fundamentals with a Challenging MCQ Assignment on " Multithreaded Programming IN jAVA " Sharpen your core Java skills with this engaging multiple-choice quiz (MCQ). Designed for beginners, this Assignment 7 assesses your understanding of fundamental Java concepts. Whether you're new to programming or refreshing your knowledge, this MCQ [Java Multithreaded Programming ] challenge is a perfect way to gauge your progress and identify areas for improvement.

Multithreaded Programming IN jAVA mcq

Learn Java Programming for free with Computer Course - CompEduBox Android app. Share with your Friends

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. Byte stream,d. Character stream



Java defines only two types of streams: Byte stream and character stream. Others are not streams.

Which of the following is a class in java.io package?

a. FileReader
b. ObjectInput
c. ObjectOutput
d. DataInput
Answer

a. FileReader



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

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(64+'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 compile-time error.
b. B
c. 66
d. r
Answer


d. r

The expression 64+'2' add 64 with 50(i.e, Ascii value of 2)=114 and print the corresponding char, in this case, r.

Consider the following program.

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

What is the output of the above code?

a. java/programm/2023
b. java/programm/
c. java
d. 2023
Answer

d. 2023

Test by run.

Learn Java Programming for free with Computer Course - CompEduBox Android app. Share with your Friends

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

b. public int read(byte[ ] b)throws IOException{}

public int read(byte[ ] b)throws IOException{} is used to read b length bytes from the input stream into an array.

How many standard streams Java can support?

a. 2
b. 3
c. 4
d. 1
Answer

b. 3

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.

Which of the following stream is different from others?

a. System.in
b. System.out
c. PrintStream
d. FileOutputStream
Answer

c. PrintStream

Print stream is a virtual stream, which add functionality to already existing streams by wrapping them in a new object. All others are physical streams (i.e., tied to some IO device that is producing or consuming bytes or characters).

Which of the following is used to read a string from the input stream?

a. get( )
b. readLine( )
c. getLine( )
d. read( )
Answer

b. readLine( )

readLine() : Reads the next line of text from the input stream and return it as a String.

Which of the following class(es) can be used for handling files in Java?

a. java.files
b. java.io.File
c. java.io
d. java.Filehandling
Answer

b. java.io.File

To access the file handling methods, we need to use Java.io.File.

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. 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.

All options are correct.

PYQ | The Joy of Computing using Python - Course | NPTEL

Learn Java Programming for free with Computer Course - CompEduBox Android app. Share with your Friends

Post a Comment

0 Comments