Font size
WorksheetsBatch-2_Test-2
Total questions: 87
Worksheet time: 50mins
Which statement is true about java ?
Java is a sequence-depended programming language
Java is a code dependent programming language
Java is a platform-dependent programming language
Java is a platform-independent programming language
Which component is used to compile,debug and execute the java programs ?
JRE
JIT
JDK
JVM
Which one of the following is not a java feature
Object-oriented
Use of pointers
Portable
Dynamic and Extensible
Which of these cannot be used for a variable name in java ?
Identifier & keyword
Identifier
Keyword
None of the mentioned
Which of the following is not an OOPS concept in java ?
Polymorphism
Inheritance
Compilation
Encapsulation
Which of these are selection statements in java
Break
Continue
For ( )
If ( )
Which of these keywords is used to define interfaces in java
intf
Intf
interface
Interface
Which of the following is a superclass of every class in java ?
ArrayList
Abstract class
Object class
String
Which of these packages contains the exception stack Overflow in java ?
Which of these statements is incorrect about tread ?
Start() method is used to begin execution of the thread
Run () method is used to begin execution of a thread before start() method in special cases
A thread can be formed by implementing runnable interface only
A thread can be formed by a class that extends thread class
Which of these keywords are used for the block to be examined for exceptions ?
Check
Throw
Catch
Try
Which one of the following is not an access modifier ?
Protected
Void
Public
Private
What is the numerical range of a char data tupe in java ?
0 to 256
-128 to 127
0 to 65535
0 to 32767
When does method overloading is determined?
At run time
At compile time
At coding time
At execution time
When overloading does not occur ?
More than one method with same name but different method signature and different number or type of parameters
More than one method with same name,same signature but different number of signature
More than one method with same name,same signature,same number of parameters but different type
More than one method with same , same number of parameters and type but different signature
What is it called if an object has its own life cycle and there is no owner
Aggregation
Composition
Encapsulation
Association
Method overriding is combination of inheritance and polymorphism ?
True
False
Which of the below is invalid identifier with the main method
Public
Static
Private
Final
How can we identify whether a compilation unit is class or interface from a .class file ?
Java source file header
Extension of compilation unit
We cannot different between class and interface
The class or interface name should be postfixed with unit type
What is use of interpreter ?
They covert bytecode to machine language code
They read high level code and execute them
They are intermediated between JIT and JVM
It is a synonym for JIT
1. Which of this method is given parameter via command line arguments?
a) main()
b) recursive() method
c) Any method
d) System defined methods
What are the Type Conversions available in Java language?
A) Narrowing Type Conversion
B) Widening Type Conversion
A and B
D) None of the above
What is the output of the below Java code snippet?
char ch = 'A';//ASCII 65
int a = ch + 1;
ch = (char)a;
System.out.println(ch);
A) 66
B) A
C) B
D) 65
Which type of loop is best known for its boolean condition that controls entry to the loop?
A. do-while loop
B. for (traditional)
C. for-each
D. while
What will be the Output of the below code:
public class Demo{
public static void main(String[] arr){
}
public static void main(String arr){
}
}
a) Nothing
b) Error
C) Finite
d) Hii
char is 2 byte in storage?
True
False
Name the data type: '3'
int
char
String
None of the above
What data type would you use for storing the number of students in a class?
boolean
String
double
int
What is the output of the below Java code snippet?
char ch = 'A';//ASCII 65
int a = ch + 1;
ch = (char)a;
System.out.println(ch);
A) 66
B) A
C) B
D) 65
What is the output of the following code snippet?
int i = 0; for(i = 0 ; i < 5; i++)
{ }
System.out.println(i);
A. 5
B. 0
C. 4
D. Compilation Error
Function of the Scanner class to accept a float literal from the user is
nextInt( )
hasNext( )
next( )
nextFloat( )
Predict the value of k,
int k =10;
k=k+k++;
11
20
21
22
Which of the following key word is optional in Exception handling program
try
catch
finally
throw
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
Exception classes belongs to following package
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
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
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
Find the output for the following.
public class IncDec
{
public static void main(String s[])
{
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
System.out.println("a = " + a);
System.out.print("b = " + b);
System.out.println("c = " + c);
System.out.print("d = " + d);
}
}
a = 2 b = 3 c = 4 d = 1
a = 2 b = 3 c = 4 d = 1
Program does not compile.
a = 1 b = 2 c = 4 d = 2
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
Bank tom = new Bank(5000.0);
Which is the class?
Bank tom = new Bank(5000.0);
Which is the object?
which package is imported implicitly?
java.applet
java.util
java.lang
java.io
Classes in Java are:
Abstract data types, used as a template of objects
Where students learn
Dungeons and Dragons Character types
None of these
To create an object in java we use the keyword new.
True
False
Which is the fundamental unit of OOP?
Object
Class
Class is a_________.
object / Template
blue print / Template
Instance / blue print
TextBook English=new Textbook();
In the above snippet, TextBook is a _______.
Object
Data member
Member function
Class
TextBook English=new Textbook();
In the above snippet, English is an _______.
Object
Class
Member function
Class name
The process of binding data and functions is called as
Inheritance
Polymorphism
Abstraction
Encapsulation
The process of hiding the implementation details from the user is called
Abstraction
Polymorphism
Inheritance
Encapsulation
A class can have any number of objects
false
true
neither true nor false
cannot say
The OOPs concept, exposing only necessary information to users or clients is known as
Inheritance
Insulation
Abstraction
Polymorphism
Predict the output of following Java program?
class Test {
int i;
}
class Main {
public static void main(String args[]) {
Test t;
System.out.println(t.i);
}
0
garbage value
Compiler Error
Run Time Error
Predict the output of following Java program
class Test
{ int i;
}
class Main
{ public static void main(String args[])
{ Test t = new Test();
System.out.println(t.i);
} }
Garbage Value
0
Compiler Error
Runtime error
Tools that provide support for software development process including editors and debuggers are called
integrated development environments
bytecode converters
virtual machine converters
memory verifier
Which of the following is not a feature of Java
Robust
Platform Specific
Multithreaded
Object-Oriented
Among the following list, which is/are the optional items that can be present in a Java Program
Documentation Section
Import Statements
Main Method Class
Package declaration
The presence of JVM makes java program platform independent.
True
False
Advantages of OOPs
Code Reusability
Easy Maintenance
Security
Use of Procedures
Pure OOP can be implemented without using class in a program. (True or False)
True
False
What is the output of the following code snippet?
public class MyClass {
public static void main(String[] args) {
int x = 5;
System.out.println(x++ + ++x);
}
}
10
11
12
13
What will be the output for the following program?
Hello Hello Hello
Compile time error
Hello (Infinitely)
No output
What will be the output of the following program?
i = 15 j = 13 k = 759
i = 16 j = 16 k = 297
i = 11 j = 10 k = 801
i = 15 j = 13 k = 808
Program goes into infinite loop
What will be the output of the following program?
n = 5
n = 4
n = 3
n = 2
n = 1
n = 4
n = 3
n = 2
n = 1
Compilation Error
n = 5
n = 4
n = 3
n = 2
n = 1
n = 0
A CONTINUE statement inside a Loop like WHILE, FOR, DO-WHILE and Enhanced-FOR causes the program execution ___ the loop.
A) Skip
Skip present iteration and continue with next iteration of the loop
Exit
None
Choose the Java-Code below with a never-ending loop.
while(true);
for(;true;);
do
{
;
}while(true);
All
An Increment operator "++" and/or a Decrement operator "--" are used along with a Loop-Counter variable in Java.
TRUE
FALSE
What is the output of the below Java program?
1 2 3 4
1 2 3
6
Compiler error
What is the output of the below Java program?
0
1
2
3
1 2
An IF or ELSE IF statement accepts ___ as input before branching.
boolean
int
float
chae
What is the output of the Java program?
OK MASTER
BYE
Compiler error
None
public class MyClass {
public static void main(String[] args) {
(a) ("Hello World");
}
}
