Font size
WorksheetsBCD-MNO- Quiz-3
Total questions: 149
Worksheet time: 1hrs 14mins
What will be the output of the following code?
12
24
20
18
What will be the output of the code?
JAVA
java
418
None of the Options
What will be the output of the code?
Error: invalid identifier
25
55555
None of the options
What will be the output of the C program?
Compilation
Error
Infinite Loop
Loop Loop Loop Loop Loop
None of the Options
Consider the following Java Code. What is the correct option?
Infinite Loop
Error: Condition Expression of for
Prints Hello
None of the Options
What is the output of the code Snippet
0
1
Compilation
Error
RunTime
Error
What is the output of the following code?
8
10
Compilation
Error
RunTime
Error
Guess the output of the given code.
1
-1
2
-2
_____ Tells a compiler that the data would be defined somewhere and it would be connected to the Linker.
Variable
yvals
errno
extern
Identify the programming Language
Golang
Kotlin
Swift
Python
Guess the output of the given code
1
120
0
None of the choices
Which is the correct absolute path of a file in Java?
C:\Program Files\Java\jdk1.8.0_131\bin\file_name.txt
C:\Program Files\Java\file_name.txt
C:\Program Files\Java\jdk1.8.0_131\file_name.txt
C:\Program Files\Java\jdk1.8.0_131\bin\File Handling\file_name.txt
Guess the output of the below Program
-2147483648 and 1
0x80000000 and
0x00000001
-2147483648 and -1
1 and -2147483648
Which is a valid declaration within an interface?
public static short stop = 23;
protected short stop = 23;
transient short stop = 23;
final void madness(short stop);
Identify the father of the swift programming language?
JetBrains
Christopher Arthur Lattner
Grace Murray Hooper
Brendan Eich
Java is a
Procedure Oriented Language
Structure Oriented Language
Object_Oriented Language
Machine Language
The name of the following should be the file name in Java
Object Name
Variable Nam
Class Name
Array Name
Java program is
Interpreted
Compiled
Java program does not run without below function
user()
system()
main()
void()
A ___________ file is created after successful compilation of a Java program.
Object file
Array file
Class file
String file
Command to compile Java program
javax
javay
javac
Java
Command to run a Java program
javaa
java
jaava
jaavaa
JDK stands for
Java Developer Kit
Java Development Kit
Java Design Kit
Java Debugging Kit
JRE stands for
Java Run Environment
Java Run Execution
Java Runtime Environment
Java Ready Execution
Java is
Machine dependent language
Machine independent language
What is the advantage of Exception Handling
To avoid abnormal termination of a program
To find out errors
To Debug program
None of these
What is the parent class of All Exceptions in JAVA
Throw
Exception
Error
Bug
Which of the following key word is optional in Exception handling program
try
catch
finally
throw
try block may or may not contains catch blocks
True
False
What is the purpose of 'throw' keyword
To Raise an exception explicityly
To Raise an exception implicityly
To create user defined exceptions
To create custom exceptions
What is an exception
Error occurred during the execution of a program
Bug occurred during the compile time of a program
Simply an Error
It is related to input values
How to create our own exception
using 'throw' keyword
using 'throws' keyword
using 'finally' keyword
using 'throwable' keyword
Exception classes belongs to following package
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
Which of these keywords is not a part of exception handling?
try
finally
thrown
catch
java.lang.NullPointerException is a
Error
runtime exception
Compile time exception
None
Which of these class is highest in hierarchy in java
java.lang.Exception
java.lang.Error
java.lang.Throwable
java.lang.Object
Choose the CORRECT exception
String department="JTMK";
Integer no=Integer.parseInt(department);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundsException
Choose an exception if attempt to divide number by zero
int number = 89 / 0;
System.out.println("The answer is " + number);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundException
What will it print?
1
2
3
30
1
2
30
1
2
3
11
1
2
11
Which line or lines should we get inside a try block to avoid errors?
3
4
6
2
What will this print?
There was an error
1
9
0
What will this program print?
Nothing, there is an error
There was a ValueError, please try again
num1num2
num2num1
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
Finally
Compilation fails.
The code runs with no output
An exception is thrown at runtime.
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");
finished
runtime error.
Compilation fails
Exception.
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 */
}
}
ABCD
Compilation fails.
C is printed before exiting with an error message.
BC is printed before exiting with an error message
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();
}
}
BD
BDE
BD
DE
FileNotFoundException
Is a subclass/extends IOException
Is a Compile time exception
Found in java.io package
All
class Main {
public static void main(String args[]) {
try {
throw 10;
}
catch(int e) {
System.out.println("Got the Exception " + e);
}
}
}
Got the Exception 10
Got the Exception 0
Compiler Error
none
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
B
AC
BC
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.
NumberFormatException
NullPointerException
ArrayIndexOutOfBoundsException
InvalidStringException
class IT
{
static public void main(String...args)
{
String s=null;
System.out.println("length is:"+s.length());
}
}
It throws NullPointerException
it throws IOException
It throws StringExeption
output is 0
What is event handling in programming?
Managing errors in code
Responding to user interactions
Running background processes
Creating user interfaces
Which of the following is an example of a user interface event?
Clicking a button
Compiling code
Processing data
Writing a file
Which programming concept is used to handle events?
Looping
Inheritance
Polymorphism
Event-driven programming
What is an event handler?
A function that handles errors
A method that triggers events
A class that manages user interfaces
A subroutine that responds to events
Which programming language is commonly used for event handling in web development? a. Python
Java
Python
C++
JavaScript
Which event is triggered when a user hovers over an element on a webpage?
onclick
onhover
onmouseover
onmouseenter
What is event propagation in event handling?
Stopping the execution of an event
Bubbling up or capturing down events in a DOM hierarchy
Creating new events programmatically
Preventing default behavior of an event
Which method can be used to stop event propagation in JavaScript?
stopEvent()
cancelEvent()
stopPropagation()
preventDefault()
What is event delegation in event handling?
Assigning multiple event handlers to an element
Dynamically creating events based on user actions
Handling events at a higher level in the DOM hierarchy
Disabling event triggering for certain elements
Which event is triggered when a form is submitted?
onsubmit
onsend
onclick
onsubmitform
What is the advantage of Exception Handling
To avoid abnormal termination of a program
To find out errors
To Debug program
None of these
What is the parent class of All Exceptions in JAVA
Throw
Exception
Error
Bug
Which of the following key word is optional in Exception handling program
try
catch
finally
throw
try block may or may not contains catch blocks
True
False
What is the purpose of 'throw' keyword
To Raise an exception explicityly
To Raise an exception implicityly
To create user defined exceptions
To create custom exceptions
What is an exception
Error occurred during the execution of a program
Bug occurred during the compile time of a program
Simply an Error
It is related to input values
How to create our own exception
using 'throw' keyword
using 'throws' keyword
using 'finally' keyword
using 'throwable' keyword
Exception classes belongs to following package
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
Which of these keywords is not a part of exception handling?
try
finally
thrown
catch
java.lang.NullPointerException is a
Error
runtime exception
Compile time exception
None
Which of these class is highest in hierarchy in java
java.lang.Exception
java.lang.Error
java.lang.Throwable
java.lang.Object
Choose the CORRECT exception
String department="JTMK";
Integer no=Integer.parseInt(department);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundsException
Choose an exception if attempt to divide number by zero
int number = 89 / 0;
System.out.println("The answer is " + number);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundException
What will it print?
1
2
3
30
1
2
30
1
2
3
11
1
2
11
Which line or lines should we get inside a try block to avoid errors?
3
4
6
2
What will this print?
There was an error
1
9
0
What will this program print?
Nothing, there is an error
There was a ValueError, please try again
num1num2
num2num1
Which of these keywords is not a part of exception handling?
try
finally
thrown
catch
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
Finally
Compilation fails.
The code runs with no output
An exception is thrown at runtime.
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");
finished
runtime error.
Compilation fails
Exception.
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 */
}
}
ABCD
Compilation fails.
C is printed before exiting with an error message.
BC is printed before exiting with an error message
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();
}
}
BD
BDE
BD
DE
java.lang.NullPointerException is a
Error
runtime exception
Compile time exception
None
FileNotFoundException
Is a subclass/extends IOException
Is a Compile time exception
Found in java.io package
All
Exception and Error are direct subclasses of?
.BaseException
Throwable
Object
RuntimeException
What block is always executed, independently of a exception being raised?
throws
finally
catch
throw
What keyword is used to explicitly raise a exception?
catch
throw
throws
raise
Which of these class is highest in hierarchy in java
java.lang.Exception
java.lang.Error
java.lang.Throwable
java.lang.Object
Exception is found in which package in java
java.lang
java.util
java.io
.java
Exception is a class/interface/abstract class/other?
Class
Interface
Abstract class
Other
class Main {
public static void main(String args[]) {
try {
throw 10;
}
catch(int e) {
System.out.println("Got the Exception " + e);
}
}
}
Got the Exception 10
Got the Exception 0
Compiler Error
none
Both class Error and class Exception are children of this parent:
A.
B.
C.
D.
Throwable
Catchable
Runable
Problem
What type of exception is thrown by parseInt() if it gets illegal data?
ArithmeticException
RunTimeException
NumberFormatException
NumberErro
The code within the ----------- block will always be executed whether or not an exception is thrown.
try
catch
finally
throw
Which exception is thrown by read() method?
IOException
InterruptedException
SystemException
SystemInputException
rom which problems is it possible for a program to recover?
Errors
Exceptions
Both errors and exceptions
Neither.
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
B
AC
BC
1. Which of these keywords must be used to monitor for exceptions?
a) try
b) finally
c) throw
d) catch
2. Class at the top of exception class hierarchy?
ArithmeticException
Throwable
Object
Exception
3. In which of the following package, Exception class exist?
java.util
java.io
java.lang
java.file
4. Exception generated by try block is caught in ______ block?
catch
throw
throws
finally
5. Which exception is thrown when divide by zero occurs?
NumberFormatException
ArithmeticException
NullPointerException
None of these
Which component is responsible for converting bytecode into machine specific code
JVM
JDK
JRE
JIT
what is used to store values in variables
rom
prom
ram
pram
in-----storage value of variable is not lost even though the computer is not supplied electricity
non volatile
volatile
a and b
none
usb stangs for
universal serial bus
universal source bus
universal secondary bus
universal section bus
data stored in the files are called
static data
persistent data
dynamic data
rough data
files that can be read bye text editors are called
text
editor
source
binary
ASCII stands for
american standard code for interchange information
American standard for information interchange
american standard code for intelligent interchange
vi stands for
visual editor
voice editor
victory editor
vector editor
in binary file data is used in
byte
text
graphics
none
JPEG stands for................
Joint Photographic Experts Group
Junior Photographic Experts Group
Joint Photographic Exchange Group
Joint Protocol Exchange Group
Java is a
Procedure Oriented Language
Structure Oriented Language
Object_Oriented Language
Machine Language
java uses the concept of
source
stream
section
standard
Who is responsible to convert .java file to .class file
jvm(Java Virtual Machine)
java Compiler(javac)
Developer
javap
class loader is a component of
jvm
javac
javap
javadoc
Which is the correct syntax to compile a java program saved as Demo.java
javac Demo.class
javac Demo
javac Demo.java
java Demo.java
java is a
platform dependent
programming language
platform independent
programming language
both platform dependent
and
independent
none of the above
Who invented java
James Anderson
James Blake
James Gosling
James Rodriguez
What is the correct syntax to execute .class file named as Test.class
javac Test
java Test
java Test.class
javac Test.class
What is the full form of JVM
Java Virtual Mobile
Java Visual Machine
Java Virtual Memory
Java Virtual Machine
What is the current version of java
java 18
java 19
java 22
java 20
Platform means
Hardware
Software
Hardware and Software
None of the above
Full form of "wora"(Java Slogan)
Write Once Run Anywhere
Write Once Run Anyplace
Write Once Read Anywhere
Write Once Read Anyplace
What is the use of “a” in file handling?
Read
Write
Append
None of the mentioned
Which function is used to read single line from file?
Readline()
Readlines()
Readstatement()
Readfullline()
Which function is used to close a file in python?
Close()
Stop()
End()
Closefile()
Is it possible to create a text file in python?
Yes
No
Machine dependent
All of the mentioned
What is the use of seek() method in files?
sets the file’s current position at the offset
sets the file’s previous position at the offset
sets the file’s current position within the file
none of the mentioned
Which of the following mode will refer to binary data?
r
w
+
b
EOL stands for
End Of Line
End Of List
End of Lines
End Of Location
Which of the following is nor a proper file access mode?
close
read
write
append
In f=open(“data.txt”, “r”), r refers to __________.
File handle
File object
File Mode
Buffer
Which of the following functions do you use to write data in the binary format?
write
output
dump
send
Which of the following command is used to open a file “c:\temp.txt” for reading in binary format only?
outfile = open(“c:\temp.txt”, “r”)
outfile = open(“c:\\temp.txt”, “rb”)
outfile = open(“c:\temp.txt”, “r+”)
outfile = open(“c:\\temp.txt”, “rb+”)
Which of the following commands can be used to read “n” number of characters from a file using the file object <file>?
file.read(n)
n = file.read()
file.readline(n)
file.readlines()
Which of the following statements are true regarding the opening modes of a file?
When you open a file for reading, if the file does not exist, an error occurs.
When you open a file for writing, if the file does not exist, an error occurs.
When you open a file for reading, if the file does not exist, the program will open an empty file.
Which of the following command is used to open a file “c:\temp.txt” in append-mode?
outfile = open(“c:/temp.txt”, “a”)
outfile = open(“c:\\temp.txt”, “rw”)
outfile = open(“c:\temp.txt”, “w+”)
outfile = open(“c:\\temp.txt”, “r+”)
outfile = open(“c:\\temp.txt”, “a”)
