Font size
WorksheetsMIDTERM -Application Dev
Total questions: 89
Worksheet time: 45mins
which one of these events will cause the thread to die?
on calling the sleep() method.
when the execution of the run() method ends
when the execution of the start() method ends
on calling the wait() method
which one this keywords are used to create a class in java
class
struct
int
none of the avove
superclass of all classes representing the output stream of characters is -------------
OutputStream
Reader
InputStream
Writer
which one of the following is a legal decelration of a two- dimensional array of integers
int[] a[] = new int[5][];
int[5][5] a = new int[][];
int a = new int[5,5];
int[][] a = new int[][5];
Which one of the following statement is not true about the collection interface?
all methods defined in set interface are also defined in collection interface
list interface extends collection interface
set interface extends collection interface
all methods defined in list interface are also defined in collection interface
which one of the following is true?
runnable interface declares the start method
Thread.start() method is used to move a thread from a new state to the runnable state
Thread.runnable() method is used to move a thread from new state to the runnable state
Thread.run() method is used to move a thread from new state to the runnable state
which of the following is wrapper class in java
Float
Integer
Double
all of above
++ increases the value of a variable by 1
assignment operator
decrement operator
increment operator
sentinel
What would the new value of A be?
A=1;
a++;
1
2
3
4
What's the value of below?
int i=5;
System.out.println(i++);
System.out.println(i);
System.out.println(++i);
5
6
7
6
6
7
6
7
8
5
5
6
Which statement(s) are equivalent to i = i + 1?
i += 1
i++
i -= 1
i--
Which are the types of operators seen? Select as many you think
bitwise operator
subtraction operator
equality operator
arithmetic operator
what is modulo operation used for ?
performs division
performs division and gives no remainder
performs division and gives remainder
does not perform division
arithmetic operators return a value. True or false?
true
false
conditional operators does not return a value
true
false
which data types work on bitwise operators?
byte
double
char
int
which type of operator it is? i + =5
addition assignment operator
conditional operator
arithmetic operator
equality operator
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
What will be the output of the program?
class Test
{
public static void main(String [] args)
{
int x=20;
String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
System.out.println(sup);
}
}
small
tiny
huge
Compilation fails
Find the output of the following snippet.
class Numbers
{
public static void main(String args[])
{
int a=20, b=10;
if((a<b)&&(b++ <25))
{
System.out.println("this is any language logic");
}
System.out.println(b);
}
}
10
12
11
Compilation Error
Please write correct output in following space-
10
20
No Output
Error
A variable that holds words
String
boolean
int
float
A dictionary
A variable that holds true or false
String
boolean
int
float
Alex Trebek
Name the data type: 1.0
double
int
char
boolean
Name the data type: "true"
boolean
char
String
double
Name the data type: false
String
boolean
int
None of the above
What data type would you use for storing the number of students in a class?
boolean
String
double
int
What data type would you use for storing the average test score in a class?
double
String
int
char
What data type would you use to store names of students?
String
char
boolean
None of these
blonde
How would you declare a variable storing the tax rate?
int taxRate = 5.1;
taxRate = "5.1";
double taxRate = 5.1;
double taxRate = "5.1";
I do hereby declare thee Sir Tax Rate
How would you declare a variable storing a person's name?
string name = "Elroy";
name String = "Elroy";
String name = Elroy;
String name = "Elroy";
Me llamo Elroy
How would you declare a variable that tells you that someone passed a class?
boolean passed = 'true';
boolean passed = true;
passed = true;
String passed = "true";
Trick question - no one passes this class
Which declaration will throw an error?
double num = 8;
int averageGrade = 89.7;
boolean done = false;
String done = "true";
What prints out "I love Java" successfully?
System.out.println(I love Java);
Systemoutprintln("I love Java);
System.out.println("I love" + " Java");
System.out.println("I love Java")
What is love? Baby dont hurt me. Dont hurt me. No more.
A computer walks into a bar...
Ouch.
Sorry, we don't server here.
ERROR 404: Does not compute
Great, computers are self-aware now.
Java was originally named
Oak
C++-++
Advanced C++
Coffee
Java is a (a) language
Choose the correct order of the Java program execution.
A. Class Loader
B. Interpretation
C. Compilation
D. Byte Code Verification
E. Java Source Code
F. Execution
E-C-A-D-B-F
A-C-B-D-F-E
E-C-B-A-D-F
E-B-C-A-D-F
Which of the following is used to load a .class file?
Class Loader
JIT compiler
Byte Code verifier
Interpreter
JVM stands for (a)
How many class files will be created for the following code?
class A { .... }
class B { .... }
public class C
{
public static void main(String args[])
{
...... } }
Note: Assume that A,B and C are in same file TestClass.java
1
2
3
0
Java is a pure object oriented programming language.
Yes
No
The keyword "method" is an another name for?
function
variable
class
object
Where does a java program starts its execution?
class
main
method
object
What will be the Output o the following code?
class Sample{
public static void main(String args[])
{
int len = args.length;
System.out.println(len);
}
}
Compilation Error
Runtime Error
The program compiles and executes successfully but prints nothing
The program compiles and executes successfully and prints 0
If we want to print "I am new to Java" in java, we have to write (a)
Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
Which of the following is not a Java features?
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
_____ is used to find and fix bugs in the Java programs.
JVM
JRE
JDK
JDB
Which of the following is a valid declaration of a char?
char ch = '\utea';
char ca = 'tea';
char cr = \u0223;
char cc = '\itea';
What does the expression float a = 35 / 0 return?
0
Not a number
Infinity
Run time exception
What does the expression float a = 35 / 0 return?
0
Not a number
Infinity
Run time exception
What does the expression float a = 35 / 0 return?
0
Not a number
Infinity
Run time exception
Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
24
23
20
25
Which of the following for loop declaration is not valid?
for ( int i = 99; i >= 0; i / 9 )
for ( int i = 7; i <= 77; i += 7 )
for ( int i = 20; i >= 2; - -i )
for ( int i = 2; i <= 20; i = 2* i )
Which of the following is not OOPS concept in Java?
Inheritance
Encapsulation
Polymorphism
Compilation
Which of the following is a type of polymorphism in Java?
Compile time polymorphism
Execution time polymorphism
Multiple polymorphism
Multilevel polymorphism
When does method overloading is determined?
At run time
At compile time
At coding time
At execution time
Which concept of Java is a way of converting real world objects in terms of class?
Polymorphism
Encapsulation
Abstraction
Inheritance
Which concept of Java is achieved by combining methods and attribute into a class?
Encapsulation
Inheritance
Polymorphism
Abstraction
Which component is used to compile, debug and execute java program?
JVM
JDK
JIT
JRE
Which of the below is invalid identifier with the main method?
public
static
final
private
What is use of interpreter?
They convert 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
What is the extension of compiled java classes?
.java
.class
.txt
.js
Which of these keywords is used to make a class?
class
struct
int
none of the mentioned
Which of these statement is incorrect?
Every class must contain a main() method
Applets do not require a main() method at all
There can be only one main() method in a program
main() method must be made public
Which of the following statements is correct?
Public method is accessible to all other classes in the hierarchy
Public method is accessible only to subclasses of its parent class
Public method can only be called by object of its class
Public method can be accessed by calling object of the public class
Which of this keyword must be used to inherit a class?
super
this
extend
extends
Which of the following statements is correct?
Public method is accessible to all other classes in the hierarchy
Public method is accessible only to subclasses of its parent class
Public method can only be called by object of its class
Public method can be accessed by calling object of the public class
Java was originally named:
Coffee
Oak
New C++
Duke
Is Android based on Java?
True
False
Who invented Java?
James Gosling
Sergey Brin
Steve Jobs
Bill Gates
Tim Berners-Lee
Which company owns Java?
Oracle
Microsoft
Apple
Intel
When saving a Java source file, save it with an extension of
.java.
.javac.
.src.
.class.
To print "Hello, world" on the monitor, use the following Java statement:
System.out.println("Hello, world");
System Print = "Hello, world";
SystemOutPrintln('Hello, world');
system.out.println{Hello, world};
Where does a java program start executing instructions from:
class
source file
main method
object
Which of the following can be operands of arithmetic operators?
Numeric
Boolean
Both Numeric & Characters
Characters
What will be the output of the following Java program?
class Output {
public static void main(String args[]) {
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
b++;
++a;
System.out.println(a + " " + b + " " + c); }
}
3 2 4
3 2 3
2 3 4
2 4 4
3 4 4
Which of these can be returned by the operator &?
Integer
Boolean
Integer or Boolean
Character
What will be the output of the following Java program?
class comma_operator {
public static void main(String args[]) {
int sum = 0;
for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
sum += i;
System.out.println(sum); }
}
5
4
6
14
Which of these can not be used for a variable name in Java?
identifier
identifier & keyword
keyword
none of the mentioned
What will be the output of the following Java code?
class operators {
public static void main(String args[]) {
int x = 8;
System.out.println(++x * 3 + " " + x); }
}
24 8
24 9
27 9
27 8
Which of the following is not an operator in Java?
instanceof
sizeof
>>>=
new
What will be the output of the following Java program?
class jump_statments {
public static void main(String args[]) {
int x = 2;
int y = 0;
for ( ; y < 10; ++y) {
if (y % x == 0)
continue;
else if (y == 8)
break;
else
System.out.print(y + " "); }
}
}
1 3 5 7
2 4 6 8
1 3 5 7 9
1 2 3 4 5 6 7 8 9
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
while
do-while
for
none of the mentioned
What will be the output of the following Java code?
class Relational_operator {
public static void main(String args[]) {
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2); }
}
5
6
true
false
Which of these is not a bitwise operator?
&
&=
|=
<=
What is the output of relational operators?
Integer
Boolean
Characters
Double
