wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

BCD-MNO- Quiz-3

Total questions: 149

Worksheet time: 1hrs 14mins

Name
Class
Date
1.
Which of these method of FileReader class is used to read characters from a file?
a)
read()
b)
scanf()
c)
get()
d)
getInteger()
2.
Which of these packages contain classes and interfaces used for input & output operations of a program?
a)
java.util
b)
java.lang
c)
java.io
d)
all of the mentioned
3.
Which of these class is not a member class of java.io package?
a)
String
b)
StringReader
c)
Writer
d)
File
4.
Which of these class is not related to input and output stream in terms of functioning?
a)
File
b)
Write
c)
InputStream
d)
Reader
5.
Which stream used to read data from a source, it may be a file, an array, peripheral device or socket?
a)
InputStream
b)
OutputStream
c)
Input/OutputStream
d)
None of the above
6.
Which is used for writing data to a file in file handling?
a)
FileInputStream
b)
FileOutputStream
c)
Both A & B
d)
None of the above
7.
public char[] readPassword() blongs to whcih class
a)
Scanner Class
b)
Console class
c)
InputStreamReader class
d)
DataInputStream
8.
Which method is used to close the Stream?
a)
close();
b)
flush();
c)
null();
d)
final();
9.
 Which exception is thrown by read() method?
a)
SystemInputException
b)
IOException
c)
SystemException
d)
InterruptedException
10.
Which of these class contains the methods print() & println()?
a)
PrintStream
b)
BUfferedOutputStream
c)
System.out
d)
System
11.

What will be the output of the following code?

a)

12

b)

24

c)

20

d)

18

12.

What will be the output of the code?

a)

JAVA

b)

java

c)

418

d)

None of the Options

13.

What will be the output of the code?

a)

Error: invalid identifier

b)

25

c)

55555

d)

None of the options

14.

What will be the output of the C program?

a)

Compilation

Error

b)

Infinite Loop

c)

Loop Loop Loop Loop Loop

d)

None of the Options

15.

Consider the following Java Code. What is the correct option?

a)

Infinite Loop

b)

Error: Condition Expression of for

c)

Prints Hello

d)

None of the Options

16.

What is the output of the code Snippet

a)

0

b)

1

c)

Compilation

Error

d)

RunTime

Error

17.

What is the output of the following code?

a)

8

b)

10

c)

Compilation

Error

d)

RunTime

Error

18.

Guess the output of the given code.

a)

1

b)

-1

c)

2

d)

-2

19.

_____ Tells a compiler that the data would be defined somewhere and it would be connected to the Linker.

a)

Variable

b)

yvals

c)

errno

d)

extern

20.

Identify the programming Language

a)

Golang

b)

Kotlin

c)

Swift

d)

Python

21.

Guess the output of the given code

a)

1

b)

120

c)

0

d)

None of the choices

22.

Which is the correct absolute path of a file in Java?

a)

C:\Program Files\Java\jdk1.8.0_131\bin\file_name.txt

b)

C:\Program Files\Java\file_name.txt

c)

C:\Program Files\Java\jdk1.8.0_131\file_name.txt

d)

C:\Program Files\Java\jdk1.8.0_131\bin\File Handling\file_name.txt

23.

Guess the output of the below Program

a)

-2147483648 and 1

b)

0x80000000 and

0x00000001

c)

-2147483648 and -1

d)

1 and -2147483648

24.

Which is a valid declaration within an interface?

a)

public static short stop = 23;

b)

protected short stop = 23;

c)

transient short stop = 23;

d)

final void madness(short stop);

25.

Identify the father of the swift programming language?

a)

JetBrains

b)

Christopher Arthur Lattner

c)

Grace Murray Hooper

d)

Brendan Eich

26.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

27.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

28.

Java program is

a)

Interpreted

b)

Compiled

29.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

30.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

31.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

32.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

33.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

34.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

35.

Java is

a)

Machine dependent language

b)

Machine independent language

36.

What is the advantage of Exception Handling

a)

To avoid abnormal termination of a program

b)

To find out errors

c)

To Debug program

d)

None of these

37.

What is the parent class of All Exceptions in JAVA

a)

Throw

b)

Exception

c)

Error

d)

Bug

38.

Which of the following key word is optional in Exception handling program

a)

try

b)

catch

c)

finally

d)

throw

39.

try block may or may not contains catch blocks

a)

True

b)

False

40.

What is the purpose of 'throw' keyword

a)

To Raise an exception explicityly

b)

To Raise an exception implicityly

c)

To create user defined exceptions

d)

To create custom exceptions

41.

What is an exception

a)

Error occurred during the execution of a program

b)

Bug occurred during the compile time of a program

c)

Simply an Error

d)

It is related to input values

42.

How to create our own exception

a)

using 'throw' keyword

b)

using 'throws' keyword

c)

using 'finally' keyword

d)

using 'throwable' keyword

43.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

44.

Which of these keywords is not a part of exception handling?

a)

try

b)

finally

c)

thrown

d)

catch

45.

java.lang.NullPointerException is a

a)

Error

b)

runtime exception

c)

Compile time exception

d)

None

46.

Which of these class is highest in hierarchy in java

a)

java.lang.Exception

b)

java.lang.Error

c)

java.lang.Throwable

d)

java.lang.Object

47.

Choose the CORRECT exception


String department="JTMK";

Integer no=Integer.parseInt(department);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundsException

48.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

49.

What will it print?

a)

1

2

3

30

b)

1

2

30

c)

1

2

3

11

d)

1

2

11

50.

Which line or lines should we get inside a try block to avoid errors?

a)

3

b)

4

c)

6

d)

2

51.

What will this print?

a)

There was an error

b)

1

c)

9

d)

0

52.

What will this program print?

a)

Nothing, there is an error

b)

There was a ValueError, please try again

c)

num1num2num1^{num2}

d)

num2num1num2^{num1}

53.

public class Foo

{

public static void main(String[] args)

{

try

{

return;

}

finally

{

System.out.println( "Finally" );

}

}

}

a)

Finally

b)

Compilation fails.

c)

The code runs with no output

d)

An exception is thrown at runtime.

54.

What will be the output of the program?

try

{

int x = 0;

int y = 5 / x;

}

catch (Exception e)

{

System.out.println("Exception");

}

catch (ArithmeticException ae)

{

System.out.println(" Arithmetic Exception");

}

System.out.println("finished");

a)

finished

b)

runtime error.

c)

Compilation fails

d)

Exception.

55.

public class X

{

public static void main(String [] args)

{

try

{

badMethod();

System.out.print("A");

}

catch (Exception ex)

{

System.out.print("B");

}

finally

{

System.out.print("C");

}

System.out.print("D");

}

public static void badMethod()

{

throw new Error(); /* Line 22 */

}

}

a)

ABCD

b)

Compilation fails.

c)

C is printed before exiting with an error message.

d)

BC is printed before exiting with an error message

56.

public class X

{

public static void main(String [] args)

{

try

{

badMethod();

System.out.print("A");

}

catch (RuntimeException ex) /* Line 10 */

{

System.out.print("B");

}

catch (Exception ex1)

{

System.out.print("C");

}

finally

{

System.out.print("D");

}

System.out.print("E");

}

public static void badMethod()

{

throw new RuntimeException();

}

}

a)

BD

b)

BDE

c)

BD

d)

DE

57.

FileNotFoundException

a)

Is a subclass/extends IOException

b)

Is a Compile time exception

c)

Found in java.io package

d)

All

58.

class Main {

public static void main(String args[]) {

try {

throw 10;

}

catch(int e) {

System.out.println("Got the Exception " + e);

}

}

}

a)

Got the Exception 10

b)

Got the Exception 0

c)

Compiler Error

d)

none

59.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

60.

class IT

{

static public void main(String...args)

{

int k=Integer.parseInt(args[0]);

System.out.println(k);

}

}

if args[0]="gec" then what type of exception is thrown by the above program.

a)

NumberFormatException

b)

NullPointerException

c)

ArrayIndexOutOfBoundsException

d)

InvalidStringException

61.

class IT

{

static public void main(String...args)

{

String s=null;

System.out.println("length is:"+s.length());

}

}

a)

It throws NullPointerException

b)

it throws IOException

c)

It throws StringExeption

d)

output is 0

62.

What is event handling in programming?

a)

Managing errors in code

b)

Responding to user interactions

c)

Running background processes

d)

Creating user interfaces

63.

Which of the following is an example of a user interface event?

a)

Clicking a button

b)

Compiling code

c)

Processing data

d)

Writing a file

64.

Which programming concept is used to handle events?

a)

Looping

b)

Inheritance

c)

Polymorphism

d)

Event-driven programming

65.

What is an event handler?

a)

A function that handles errors

b)

A method that triggers events

c)

A class that manages user interfaces

d)

A subroutine that responds to events

66.

Which programming language is commonly used for event handling in web development? a. Python

a)

Java

b)

Python

c)

C++

d)

JavaScript

67.

Which event is triggered when a user hovers over an element on a webpage?

a)

onclick

b)

onhover

c)

onmouseover

d)

onmouseenter

68.

What is event propagation in event handling?

a)

Stopping the execution of an event

b)

Bubbling up or capturing down events in a DOM hierarchy

c)

Creating new events programmatically

d)

Preventing default behavior of an event

69.

Which method can be used to stop event propagation in JavaScript?

a)

stopEvent()

b)

cancelEvent()

c)

stopPropagation()

d)

preventDefault()

70.

What is event delegation in event handling?

a)

Assigning multiple event handlers to an element

b)

Dynamically creating events based on user actions

c)

Handling events at a higher level in the DOM hierarchy

d)

Disabling event triggering for certain elements

71.

Which event is triggered when a form is submitted?

a)

onsubmit

b)

onsend

c)

onclick

d)

onsubmitform

72.

What is the advantage of Exception Handling

a)

To avoid abnormal termination of a program

b)

To find out errors

c)

To Debug program

d)

None of these

73.

What is the parent class of All Exceptions in JAVA

a)

Throw

b)

Exception

c)

Error

d)

Bug

74.

Which of the following key word is optional in Exception handling program

a)

try

b)

catch

c)

finally

d)

throw

75.

try block may or may not contains catch blocks

a)

True

b)

False

76.

What is the purpose of 'throw' keyword

a)

To Raise an exception explicityly

b)

To Raise an exception implicityly

c)

To create user defined exceptions

d)

To create custom exceptions

77.

What is an exception

a)

Error occurred during the execution of a program

b)

Bug occurred during the compile time of a program

c)

Simply an Error

d)

It is related to input values

78.

How to create our own exception

a)

using 'throw' keyword

b)

using 'throws' keyword

c)

using 'finally' keyword

d)

using 'throwable' keyword

79.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

80.

Which of these keywords is not a part of exception handling?

a)

try

b)

finally

c)

thrown

d)

catch

81.

java.lang.NullPointerException is a

a)

Error

b)

runtime exception

c)

Compile time exception

d)

None

82.

Which of these class is highest in hierarchy in java

a)

java.lang.Exception

b)

java.lang.Error

c)

java.lang.Throwable

d)

java.lang.Object

83.

Choose the CORRECT exception


String department="JTMK";

Integer no=Integer.parseInt(department);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundsException

84.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

85.

What will it print?

a)

1

2

3

30

b)

1

2

30

c)

1

2

3

11

d)

1

2

11

86.

Which line or lines should we get inside a try block to avoid errors?

a)

3

b)

4

c)

6

d)

2

87.

What will this print?

a)

There was an error

b)

1

c)

9

d)

0

88.

What will this program print?

a)

Nothing, there is an error

b)

There was a ValueError, please try again

c)

num1num2num1^{num2}

d)

num2num1num2^{num1}

89.

Which of these keywords is not a part of exception handling?

a)

try

b)

finally

c)

thrown

d)

catch

90.

public class Foo

{

public static void main(String[] args)

{

try

{

return;

}

finally

{

System.out.println( "Finally" );

}

}

}

a)

Finally

b)

Compilation fails.

c)

The code runs with no output

d)

An exception is thrown at runtime.

91.

What will be the output of the program?

try

{

int x = 0;

int y = 5 / x;

}

catch (Exception e)

{

System.out.println("Exception");

}

catch (ArithmeticException ae)

{

System.out.println(" Arithmetic Exception");

}

System.out.println("finished");

a)

finished

b)

runtime error.

c)

Compilation fails

d)

Exception.

92.

public class X

{

public static void main(String [] args)

{

try

{

badMethod();

System.out.print("A");

}

catch (Exception ex)

{

System.out.print("B");

}

finally

{

System.out.print("C");

}

System.out.print("D");

}

public static void badMethod()

{

throw new Error(); /* Line 22 */

}

}

a)

ABCD

b)

Compilation fails.

c)

C is printed before exiting with an error message.

d)

BC is printed before exiting with an error message

93.

public class X

{

public static void main(String [] args)

{

try

{

badMethod();

System.out.print("A");

}

catch (RuntimeException ex) /* Line 10 */

{

System.out.print("B");

}

catch (Exception ex1)

{

System.out.print("C");

}

finally

{

System.out.print("D");

}

System.out.print("E");

}

public static void badMethod()

{

throw new RuntimeException();

}

}

a)

BD

b)

BDE

c)

BD

d)

DE

94.

java.lang.NullPointerException is a

a)

Error

b)

runtime exception

c)

Compile time exception

d)

None

95.

FileNotFoundException

a)

Is a subclass/extends IOException

b)

Is a Compile time exception

c)

Found in java.io package

d)

All

96.

Exception and Error are direct subclasses of?

a)

.BaseException

b)

Throwable

c)

Object

d)

RuntimeException

97.

What block is always executed, independently of a exception being raised?

a)

throws

b)

finally

c)

catch

d)

throw

98.

What keyword is used to explicitly raise a exception?

a)

catch

b)

throw

c)

throws

d)

raise

99.

Which of these class is highest in hierarchy in java

a)

java.lang.Exception

b)

java.lang.Error

c)

java.lang.Throwable

d)

java.lang.Object

100.

Exception is found in which package in java

a)

java.lang

b)

java.util

c)

java.io

d)

.java

101.

Exception is a class/interface/abstract class/other?

a)

Class

b)

Interface

c)

Abstract class

d)

Other

102.

class Main {

public static void main(String args[]) {

try {

throw 10;

}

catch(int e) {

System.out.println("Got the Exception " + e);

}

}

}

a)

Got the Exception 10

b)

Got the Exception 0

c)

Compiler Error

d)

none

103.

Both class Error and class Exception are children of this parent:

A.

B.

C.

D.

a)

Throwable

b)

Catchable

c)

Runable

d)

Problem

104.

What type of exception is thrown by parseInt() if it gets illegal data?

a)

ArithmeticException

b)

RunTimeException

c)

NumberFormatException

d)

NumberErro

105.

The code within the ----------- block will always be executed whether or not an exception is thrown.

a)

try

b)

catch

c)

finally

d)

throw

106.

Which exception is thrown by read() method?

a)

IOException

b)

InterruptedException

c)

SystemException

d)

SystemInputException

107.

rom which problems is it possible for a program to recover?

a)

Errors

b)

Exceptions

c)

Both errors and exceptions

d)

Neither.

108.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

109.

1. Which of these keywords must be used to monitor for exceptions?

a)

a) try

b)

b) finally

c)

c) throw

d)

d) catch

110.

2. Class at the top of exception class hierarchy?

a)

ArithmeticException

b)

Throwable

c)

Object

d)

Exception

111.

3. In which of the following package, Exception class exist?

a)

java.util

b)

java.io

c)

java.lang

d)

java.file

112.

4. Exception generated by try block is caught in ______ block?

a)

catch

b)

throw

c)

throws

d)

finally

113.

5. Which exception is thrown when divide by zero occurs?

a)

NumberFormatException

b)

ArithmeticException

c)

NullPointerException

d)

None of these

114.

Which component is responsible for converting bytecode into machine specific code

a)

JVM

b)

JDK

c)

JRE

d)

JIT

115.

what is used to store values in variables

a)

rom

b)

prom

c)

ram

d)

pram

116.

in-----storage value of variable is not lost even though the computer is not supplied electricity

a)

non volatile

b)

volatile

c)

a and b

d)

none

117.

usb stangs for

a)

universal serial bus

b)

universal source bus

c)

universal secondary bus

d)

universal section bus

118.

data stored in the files are called

a)

static data

b)

persistent data

c)

dynamic data

d)

rough data

119.

files that can be read bye text editors are called

a)

text

b)

editor

c)

source

d)

binary

120.

ASCII stands for

a)

american standard code for interchange information

b)

American standard for information interchange

c)

american standard code for intelligent interchange

121.

vi stands for

a)

visual editor

b)

voice editor

c)

victory editor

d)

vector editor

122.

in binary file data is used in

a)

byte

b)

text

c)

graphics

d)

none

123.

JPEG stands for................

a)

Joint Photographic Experts Group

b)

Junior Photographic Experts Group

c)

Joint Photographic Exchange Group

d)

Joint Protocol Exchange Group

124.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

125.

java uses the concept of

a)

source

b)

stream

c)

section

d)

standard

126.

Who is responsible to convert .java file to .class file

a)

jvm(Java Virtual Machine)

b)

java Compiler(javac)

c)

Developer

d)

javap

127.

class loader is a component of

a)

jvm

b)

javac

c)

javap

d)

javadoc

128.

Which is the correct syntax to compile a java program saved as Demo.java

a)

javac Demo.class

b)

javac Demo

c)

javac Demo.java

d)

java Demo.java

129.

java is a

a)

platform dependent

programming language

b)

platform independent

programming language

c)

both platform dependent

and

independent

d)

none of the above

130.

Who invented java

a)

James Anderson

b)

James Blake

c)

James Gosling

d)

James Rodriguez

131.

What is the correct syntax to execute .class file named as Test.class

a)

javac Test

b)

java Test

c)

java Test.class

d)

javac Test.class

132.

What is the full form of JVM

a)

Java Virtual Mobile

b)

Java Visual Machine

c)

Java Virtual Memory

d)

Java Virtual Machine

133.

What is the current version of java

a)

java 18

b)

java 19

c)

java 22

d)

java 20

134.

Platform means

a)

Hardware

b)

Software

c)

Hardware and Software

d)

None of the above

135.

Full form of "wora"(Java Slogan)

a)

Write Once Run Anywhere

b)

Write Once Run Anyplace

c)

Write Once Read Anywhere

d)

Write Once Read Anyplace

136.

What is the use of “a” in file handling?

a)

Read

b)

Write

c)

Append

d)

None of the mentioned

137.

Which function is used to read single line from file?

a)

Readline()

b)

Readlines()

c)

Readstatement()

d)

Readfullline()

138.

Which function is used to close a file in python?

a)

Close()

b)

Stop()

c)

End()

d)

Closefile()

139.

Is it possible to create a text file in python?

a)

Yes

b)

No

c)

Machine dependent

d)

All of the mentioned

140.

What is the use of seek() method in files?

a)

sets the file’s current position at the offset

b)

sets the file’s previous position at the offset

c)

sets the file’s current position within the file

d)

none of the mentioned

141.

Which of the following mode will refer to binary data?

a)

r

b)

w

c)

+

d)

b

142.

EOL stands for

a)

End Of Line

b)

End Of List

c)

End of Lines

d)

End Of Location

143.

Which of the following is nor a proper file access mode?

a)

close

b)

read

c)

write

d)

append

144.

In f=open(“data.txt”, “r”), r refers to __________.

a)

File handle

b)

File object

c)

File Mode

d)

Buffer

145.

Which of the following functions do you use to write data in the binary format?

a)

write

b)

output

c)

dump

d)

send

146.

Which of the following command is used to open a file “c:\temp.txt” for reading in binary format only?

a)

outfile = open(“c:\temp.txt”, “r”)

b)

outfile = open(“c:\\temp.txt”, “rb”)

c)

outfile = open(“c:\temp.txt”, “r+”)

d)

outfile = open(“c:\\temp.txt”, “rb+”)

147.

Which of the following commands can be used to read “n” number of characters from a file using the file object <file>?

a)

file.read(n)

b)

n = file.read()

c)

file.readline(n)

d)

file.readlines()

148.

Which of the following statements are true regarding the opening modes of a file?

a)

When you open a file for reading, if the file does not exist, an error occurs.

b)

When you open a file for writing, if the file does not exist, an error occurs.

c)

When you open a file for reading, if the file does not exist, the program will open an empty file.

149.

Which of the following command is used to open a file “c:\temp.txt” in append-mode?

a)

outfile = open(“c:/temp.txt”, “a”)

b)

outfile = open(“c:\\temp.txt”, “rw”)

c)

outfile = open(“c:\temp.txt”, “w+”)

d)

outfile = open(“c:\\temp.txt”, “r+”)

e)

outfile = open(“c:\\temp.txt”, “a”)