0% found this document useful (0 votes)
18 views

core java questions

The document contains a series of questions and answers related to Java programming concepts, specifically focusing on inheritance, access specifiers, method overriding, and abstract classes. It includes code snippets to illustrate the questions, along with true/false statements regarding Java principles. The content is structured in a quiz format, testing knowledge on various aspects of Java programming.

Uploaded by

reddysanthosh145
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

core java questions

The document contains a series of questions and answers related to Java programming concepts, specifically focusing on inheritance, access specifiers, method overriding, and abstract classes. It includes code snippets to illustrate the questions, along with true/false statements regarding Java principles. The content is structured in a quiz format, testing knowledge on various aspects of Java programming.

Uploaded by

reddysanthosh145
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 162

Carefully read the question and answer

accordingly.
What will be the output for following code?
class Super
{
static void show()
{
System.out.println("super class show
method");
}
static class StaticMethods
{
void show()
{
System.out.println("sub class show method");
}
} super
public static void main(String[]args) class
{ show
Super.show(); method super
new Super.StaticMethods().show(); sub class class
} show show
CoreJava-Access Specifiers_Co } MCQ method method

Carefully read the question and answer


accordingly.
When one method is overridden in sub class
the access specifier of the method in sub
class should be equal as method in super
class.
CoreJava-Access Specifiers_Co State True or False. MCQ FALSE TRUE

Carefully read the question and answer


accordingly.
A class can be declared as _______ if you do
not want the class to be subclassed. Using
the __________keyword we can abstract a protected final,interf
CoreJava-Access Specifiers_Co class from its implementation MCQ ,interface ace
Carefully read the question and answer
accordingly.
The constructor of a class must not have a
CoreJava-Access Specifiers_Co return type. MCQ TRUE FALSE

Construct Construct
Carefully read the question and answer ors can ors can
accordingly. be be
Which of the following are true about overloade overridde
CoreJava-Access Specifiers_Co constructors? MCQ d n.
Carefully read the question and answer
accordingly.
A field with default access specifier can be
accessed out side the package.
CoreJava-Access Specifiers_Co State True or False. MCQ FALSE TRUE
Carefully read the question and answer
accordingly.
________ determines which member of a Inheritanc
CoreJava-Access Specifiers_Co class can be used by other classes. MCQ specifier e

Carefully read the question and answer


accordingly.
Which of the following statements are true
about Method Overriding?
I: Signature must be same including return
type
II: If the super class method is throwing the
exception then overriding method should
throw the same Exception
III: Overriding can be done in same class
IV: Overriding should be done in two different
CoreJava-Access Specifiers_Co classes with no relation between the classes MCQ I II & IV

Carefully read the question and answer


accordingly.
If display method in super class has a
protected specifier then what should be the
specifier for the overriding display method in protected protected
CoreJava-Access Specifiers_Co sub class? MCQ or default or public
Carefully read the question and answer
accordingly.
What will be the output for following code?
class Super
{
int num=20;
public void display()
{
System.out.println("super class method");
}
}
public class ThisUse extends Super
{
int num;
public ThisUse(int num)
{
this.num=num;
}
public void display()
{
System.out.println("display method");
}
public void Show()
{
this.display();
display();
System.out.println(this.num);
System.out.println(num);
}
public static void main(String[]args) super
{ class display
ThisUse o=new ThisUse(10); method method
o.Show(); display display
} method method
CoreJava-Access Specifiers_Co } MCQ 20 20 10 10
Carefully read the question and answer
accordingly.
What will be the output of following code?
class Super2
{
public void display()
{
System.out.println("super class display
method");
}
public void exe()
{
System.out.println("super class exe
method");
display();
}
}
public class InheritMethod extends Super2
{
public void display()
{

System.out.println("sub class display


method");
}

public static void main(String [] args)


{
super
InheritMethod o=new InheritMethod(); super class exe
class exe method
o.exe(); method super
} sub class class
display display
CoreJava-Access Specifiers_Co } MCQ method method
Carefully read the question and answer
accordingly.
Which of the following method is used to
CoreJava-Access Specifiers_Co initialize the instance variable of a class. MCQ Class Public

If one
class is
having
protected
method
then the
method is
available
for
subclass A class
Carefully read the question and answer which is can be
accordingly. present in declared
Which of the following are true about another as
CoreJava-Access Specifiers_Co protected access specifier? MCQ package protected.
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class Variables
{
public static void main(String[]args)
{
public int i=10;
System.out.println(i++);
}
CoreJava-Access Specifiers_Co } MCQ 10 11

Carefully read the question and answer


accordingly.
Constructor of an class is executed each time
CoreJava-Access Specifiers_Co when an object of that class is created MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Which of the following correctly fits for the Aggregati Compositi
CoreJava-Inheritance, Interfacesdefinition 'holding instances of other objects'? MCQ on on

Carefully read the question and answer


accordingly.
public abstract class Shape
{
private int x;
private int y;
public abstract void draw();
public void setAnchor(int x, int y)
{
this.x = x;
this.y = y;
}
}
Which two classes use the Shape class
correctly?
1.public class Circle implements Shape {
private int radius;
}
2.public abstract class Circle extends Shape {
private int radius;
}
3.public class Circle extends Shape {
private int radius;
public void draw();
}
4.public class Circle extends Shape {
private int radius;
public void draw() {/* code here */}
CoreJava-Inheritance, Interfaces} MCQ 1&2 1&3
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
If any method overrides one of it’s super class
methods, we can invoke the overridden
CoreJava-Inheritance, Interfacesmethod through the this keyword. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What will be the output for following code?
class super3{
int i=10;
public super3(int num){
i=num;
}
}
public class Inherite1 extends super3{
public Inherite1(int a){
super(a);
}
public void Exe(){
System.out.println(i);
}
public static void main(String[]args){
Inherite1 o=new Inherite1(50);
super3 s=new Inherite1(20);
System.out.println(s.i);
o.Exe();
}
CoreJava-Inheritance, Interfaces} MCQ 10 50 20 50
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
An abstract class cannot contain non abstract
CoreJava-Inheritance, Interfacesmethods MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
What is the outputof below code:
package p1;
class Parent {
public static void doWork() {
System.out.println("Parent");
}
}
class Child extends Parent {
public static void doWork() {
System.out.println("Child");
}
}
class Test {
public static void main(String[] args) {
Child.doWork();
} Child
CoreJava-Inheritance, Interfaces} MCQ Parent Parent

Carefully read the question and answer


accordingly.
interface A
{
public abstract void aM1();
public abstract void aM2();
}
interface B extends A
{
public void bM1();
public void bM2();
}
public class Demo extends Object public public
implements B void void
{ aM1(){} bM1(){}
} public public
In above scenario class Demo must override void void
CoreJava-Inheritance, Interfaceswhich methods? MCQ aM2(){} bM2(){}
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
The below code will compile & provide
desired output:
package p1;
interface Bounceable {
void bounce();
void setBounceFactor(int bf);
private class BusinessLogic
{
int var1;
float var2;
double result(int var1,float var2){
return var1*var2;
}
}
}
class Test {
public static void main(String[] args) {
System.out.println(new
Bounceable.BusinessLogic().result(12,12345.
22F));
}
CoreJava-Inheritance, Interfaces} MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Choose the correct option.
Statement I: When an abstract class is sub
classed, the subclass should provide the
implementation for all the abstract methods in
its parent class.
Statement II: If the subclass does not Statement
implement the abstract method in its parent Statement I is TRUE
class, then the subclass must also be I & II are & II is
CoreJava-Inheritance, Interfacesdeclared abstract. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Choose the correct option.
Statement I: A subclass inherits all of the
“public” and “protected” members of its
parent, no matter what package the subclass
is in. Statement
Statement II: If the subclass of any class is in Statement I is TRUE
the same package then it inherits the default I & II are & II is
CoreJava-Inheritance, Interfacesaccess members of the parent. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
The below code will compile & provide
desired output:
package p1;
class Parent {
private int doWork(){
System.out.println("Do Work - Parent");
return 0;
}
}
class Child extends Parent {
public void doWork(){
System.out.println("Do Work - Child");
}
}
class Test{
public static void main(String[] args) {
new Child().doWork();
}
CoreJava-Inheritance, Interfaces} MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
If any class has at least one abstract method
CoreJava-Inheritance, Interfacesyou must declare it as abstract class MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
public interface Status
{
/* insert code here */ int MY_VALUE = 10;
}
Which are valid on commented line?
1.final
2.static
3.native
CoreJava-Inheritance, Interfaces4.public MCQ 1&2 1&2&3

Carefully read the question and answer


accordingly.
Choose the correct option.
Statement I: When all methods in a class are
abstract the class can be declared as an
interface. Statement
Choose the correct option. Statement I is TRUE
Statement II: An interface defines a contract I & II are & II is
CoreJava-Inheritance, Interfacesfor classes to implement the behavior. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
abstract class Vehicle
{
public int speed()
{
return 0;
}
}
class Car extends Vehicle
{
public int speed()
{
return 60;
}
}
class RaceCar extends Car
{
public int speed()
{
return 120;
}
}
public class Demo
{
public static void main(String [] args)
{
RaceCar racer = new RaceCar();
Car car = new RaceCar();
Vehicle vehicle = new RaceCar();
System.out.println(racer.speed() + ", " +
car.speed()+", " + vehicle.speed());
}
}
CoreJava-Inheritance, InterfacesWhat is the result? MCQ 0, 0, 0 120, 60, 0

Carefully read the question and answer


accordingly.
What will be the output for following code
public class
MethodOverloading {
int m=10,n;
public void div(int a) throws Exception{
n=m/a;
System.out.println(n);
}
public void div(int a,int b) {
n=a/b;
}
public static void main(String[]args) throws
Exception{
MethodOverloading o=new
MethodOverloading(); It will print
o.div(0); Arithmetic
o.div(10,2); Exception It will give
} and prints Arithmetic
CoreJava-Inheritance, Interfaces} MCQ 5 Exception
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
The below code will compile & provide
desired output:
package p1;
abstract class LivingThings{
public abstract void resperate();
interface Living
{
public abstract void walk();
}
}
class Human implements LivingThings.Living{
@Override
public void walk() {
System.out.println("Human Can Walk");
}
}
class Test {
public static void main(String[] args) {
new Human().walk();
}
CoreJava-Inheritance, Interfaces} MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
An overriding method can also return a
subtype of the type returned by the
CoreJava-Inheritance, Interfacesoverridden method. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
abstract public class Employee
{
protected abstract double getSalesAmount();
public double getCommision() {
return getSalesAmount() * 0.15;
}
}
class Sales extends Employee
{
// insert method here
}
Which two methods, inserted independently,
correctly complete the Sales
class?
1.double getSalesAmount() { return 1230.45; }
2. public double getSalesAmount() { return
1230.45; }
3.private double getSalesAmount() { return
1230.45; }
4.protected double getSalesAmount() { return
CoreJava-Inheritance, Interfaces1230.45; } MCQ 1&2 1&3

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
The below code will compile & provide
desired output:
package p1;
interface A {
public abstract void methodOne();
}
interface B extends A {
public abstract void methodTwo();
}
class C implements B{
@Override
public void methodTwo() {
System.out.println("Method Two Body");
}
}
class Test {
public static void main(String[] args) {
new C().methodTwo();
}
CoreJava-Inheritance, Interfaces} MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
interface B
{
public void bM1();
public void bM2();
}
abstract class A implements B
{
public abstract void aM1();
public abstract void aM2();
public void bM1(){}
}
public class Demo extends A
{
} public public
In above scenario class Demo must override void void
CoreJava-Inheritance, Interfaceswhich methods? MCQ aM2(){} aM1(){}

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
Interface can be used when common
functionalities have to be implemented
CoreJava-Inheritance, Interfacesdifferently across multiple classes. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
The below code will compile & provide
desired output:
package p1;
interface A {
public abstract void methodOne();
}
interface B{
public abstract void methodTwo();
}
interface C{
public abstract void methodTwo();
}
class D implements B,C,A{
public void methodOne(){}
public void methodTwo()
{ System.out.println("Method Two");}
}
class Test {
public static void main(String[] args) {
new D().methodTwo();
}
CoreJava-Inheritance, Interfaces} MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
public class Person
{ The
private String name; equals Compilati
public Person(String name) { this.name = method on fails
name; } does NOT because
public boolean equals(Person p) properly the
{ override private
return p.name.equals(this.name); the Object attribute
} class's p.name
} equals cannot be
CoreJava-Inheritance, InterfacesWhich statement is true? MCQ method. accessed.
Carefully read the question and answer
accordingly.
Which of the following keywords ensures that
CoreJava-Inheritance, Interfacesa method cannot be overridden? MCQ final protected

Carefully read the question and answer


accordingly.
What is the outputof below code:
package p1;
abstract class LivingThings{
public abstract int walk();
}
class Human extends LivingThings{
@Override
public void walk() {
System.out.println("Human Can Walk");
}
}
class Test {
public static void main(String[] args) {
new Human().walk();
} Human Compilati
CoreJava-Inheritance, Interfaces} MCQ Can Walk on Error
Carefully read the question and answer
accordingly.
What will be the output of following code?
class InterfaceDemo
{
public static void main(String [] args)
{
new DigiCam(){}.doCharge();
new DigiCam(){
public void writeData (String msg)
{
System.out.println("You are Sending: "+msg);
}
}.writeData("MyFamily.jpg");
}//main
}
interface USB
{
int readData();
void writeData(String input);
void doCharge();
}
abstract class DigiCam implements USB
{
public int readData(){ return 0;} DigiCam
public void writeData(String input){} do
public void doCharge() Charge
{ You are
System.out.println("DigiCam do Charge"); Sending:
} MyFamily. Compilati
CoreJava-Inheritance, Interfaces} MCQ jpg on Error

Carefully read the question and answer


accordingly.
What is the output of below code:
package p1;
public class Test {
public static void main(String[] args) {
Test t1 = new Test();
Test t2 = new Test();
if (!t1.equals(t2))
System.out.println("they're not equal");
if (t1 instanceof Object)
System.out.println("t1's an Object");
} they're t1's an
CoreJava-Inheritance, Interfaces} MCQ not equal Object

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
A concrete class can extend more than one
super class whether that super class is either
CoreJava-Inheritance, Interfacesconcrete or abstract class MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
public class Client1
{
public static void main(String [] args)
{
PenDrive p;
PenDrive.Vendor v1=new
PenDrive.Vendor("WD",500);
System.out.println(v1.getName());
System.out.println(v1.getPrice());
}
}
class PenDrive
{
static class Vendor
{
String name;
int price;
public String getName(){ return name;}
public int getPrice(){ return price;}

Vendor(String name,int price)


{
this.name=name; Class
this.price=price; cannot be
} defined
} inside
} another Runtime
CoreJava-Inheritance, InterfacesWhat will be the output of the given code? MCQ class Error.
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
The super() call can only be used in
CoreJava-Inheritance, Interfacesconstructor calls and not method calls. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Abstract classes can be used when
Statement I: Some implemented
functionalities are common between classes Statement
Statement II: Some functionalities need to be Statement I is TRUE
implemented in sub classes that extends the I & II are & II is
CoreJava-Inheritance, Interfacesabstract class MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
class InterfaceDemo
{
public static void main(String [] args)
{
DigiCam cam1=new DigiCam();
cam1.doCharge();
}//main
}
interface USB
{
int readData();
boolean writeData(String input);
void doCharge();
}
class DigiCam implements USB
{
public int readData(){ return 0;} Code will
public boolean writeData(String input){ return not
false; } compile
void doCharge(){ return;} due to Code will
} weaker Compile
Which of the following is correct with respect access without
CoreJava-Inheritance, Interfacesto given code? MCQ privilege. any Error

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
Object class provides a method named
getClass() which returns runtime class of an
CoreJava-Inheritance, Interfacesobject. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class VariableDec1
{
public static void main(String[]args)
{
int I=32;
char c=65;
char a=c+I;
System.out.println(a);
}
CoreJava-Keywords_Variables_O
} MCQ 97 a
Carefully read the question and answer
accordingly.
Which of the following code snippets make
objects eligible for Garbage Collection?
Statement A: String s = "new string"; s =
s.replace('e', '3');
Statement B:String replaceable =
"replaceable"; StringBuffer sb = new Both
StringBuffer(replaceable);replaceable = null; Statement Statement
CoreJava-Keywords_Variables_O
sb = null; MCQ s A and B A alone
Carefully read the question and answer
accordingly.
Members of the classs are accessed by
CoreJava-Keywords_Variables_O
_________ operator MCQ address dot
Carefully read the question and answer
accordingly. System.s
Which of the following is the correct syntax for etGarbag
suggesting that the JVM to performs garbage System.fr eCollectio
CoreJava-Keywords_Variables_O
collection? MCQ ee(); n();

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class VariableDec
{
public static void main(String[]args)
{
int x = 1;
if(x>0 )
x = 3;
switch(x)
{
case 1: System.out.println(1);
case 0: System.out.println(0);
case 2: System.out.println(2);
break;
case 3: System.out.println(3);
default: System.out.println(4);
break;
}
}
CoreJava-Keywords_Variables_O
} MCQ 102 34
Carefully read the question and answer
accordingly.
_____________ Operator is used to create
CoreJava-Keywords_Variables_O
an object. MCQ class new
Carefully read the question and answer
accordingly.
Which of the following is not the Java implemen
CoreJava-Keywords_Variables_O
keyword? MCQ extends ts
Carefully read the question and answer
accordingly.
Find the keyword(s) which is not used to
CoreJava-Keywords_Variables_O
implement exception MCA try catch
Carefully read the question and answer
accordingly.
The ++ operator postfix and prefix has the
CoreJava-Keywords_Variables_O
same effect MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class Operators
{
public static void main(String[]args)
{
int i=12;
int j=13;
int k=++i-j--;
System.out.println(i);
System.out.println(j);
System.out.println(k);
}
CoreJava-Keywords_Variables_O
} MCQ 12,12,-1 13,12,0

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class Variabledec {
public static void main(String[]args){
boolean x = true;
int a;
if(x) a = x ? 2: 1;
else a = x ? 3: 4;
System.out.println(a);
}
CoreJava-Keywords_Variables_O
} MCQ 1 3

Carefully read the question and answer


accordingly.
What is the correct structure of a java
program?
I: import statement
II: class declaration
III: package statement III->I->II- I->III->II-
CoreJava-Keywords_Variables_O
IV: method,variable declarations MCQ >IV. >IV

Carefully read the question and answer


accordingly.
Garbage collector thread is a daemon thread.
CoreJava-Keywords_Variables_O
State True or False. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Garbage collection guarantee that a program
will not run out of memory. State True or
CoreJava-Keywords_Variables_O
False. MCQ FALSE TRUE
Carefully read the question and answer
accordingly.
Statement A:finalize will always run before an Statement
object is garbage collected Both A is true
Statement B:finalize method will be called Statement and
only once by the garbage collector s A and B Statement
CoreJava-Keywords_Variables_O
which of the following is true? MCQ are true B is false

Carefully read the question and answer


accordingly.
After which line the object initially referred by
str ("Hello" String object) is eligible for
garbage collection?
class Garbage{
public static void main(string[]args){
line 1:String str=new String("Hello");
line 2. String str1=str;
line 3.str=new String("Hi");
line 4.str1=new String("Hello Again");
5.return;
}
CoreJava-Keywords_Variables_O
} MCQ line 3 line 4

Carefully read the question and answer


accordingly.
How can you force garbage collection of an
object?
1.Garbage collection cannot be forced
2.Call System.gc().
3.Call Runtime.gc().
4. Set all references to the object to new
CoreJava-Keywords_Variables_O
values(null, for example). MCQ Option 2 Option 3

Carefully read the question and answer


accordingly.
CoreJava-Threads-Knowledge Which of the below is invalid state of thread? MCQ Runnable Running

Carefully read the question and answer


accordingly.
Predict the output of below code:
package p1;
class MyThread extends Thread {
public void run(int a) {
System.out.println("Important job running in
MyThread");
}
public void run(String s) {
System.out.println("String in run");
}
}
class Test {
public static void main(String[] args) {
MyThread t1=new MyThread(); Important
t1.start(); job
} Compile running in
CoreJava-Threads-Knowledge } MCQ Error MyThread
Support
Carefully read the question and answer Reduce parallel
accordingly. response operation
Which of these is not a benefit of time of of
CoreJava-Threads-Knowledge Multithreading? MCQ process. functions.

Carefully read the question and answer


accordingly.
You have created a TimeOut class as an
extension of Thread, the purpose of which is
to print a “Time’s Over” message if the
Thread is not interrupted within 10 seconds of
being started. Here is the run method that you
have coded:
public void run() { Exactly
System.out.println(“Start!”); 10 Exactly
try { seconds 10
Thread.sleep(10000); after the seconds
System.out.println(“Time’s Over!”); start after the
} catch (InterruptedException e) { method is “Start!” is
System.out.println(“Interrupted!”); called, printed,
} “Time’s “Time’s
}Given that a program creates and starts a Over!” will Over!” will
TimeOut object, which of the following be be
CoreJava-Threads-Knowledge statements is true? MCQ printed. printed.
Carefully read the question and answer
accordingly. Synchroni Synchroni
Synchronization is achieved by using which of zed zed
CoreJava-Threads-Knowledge the below methods MCA blocks methods

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
The below code will compile & provide
desired output:
package p1;
class MyThread extends Thread {
public void run() {
System.out.println("Important job running in
MyThread");
}
public void run(String s) {
System.out.println("String in run is " + s);
}
}
class Test {
public static void main(String[] args) {
MyThread t1=new MyThread();
t1.start();
}
CoreJava-Threads-Knowledge } MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
What will be the output of below code:
package p1;
class MyThread extends Thread {
public void run() {
System.out.println("Important job running in
MyThread");
}
}
class Test {
public static void main(String[] args) {
MyThread t1=new MyThread(); Important
t1.run(); job
} Compile running in
CoreJava-Threads-Knowledge } MCQ Error MyThread

Carefully read the question and answer


accordingly.
public class Threads
{
public static void main (String[] args)
{
new Threads().go();
}
public void go()
{
Runnable r = new Runnable()
{
public void run()
{
System.out.print("Run");
}
};

Thread t = new Thread(r);


t.start(); An The code
t.start(); exception executes
} is thrown normally
} at and prints
CoreJava-Threads-Knowledge What will be the result? MCQ runtime. "Run".
Carefully read the question and answer
accordingly.
Inter thread communication is achieved using
CoreJava-Threads-Knowledge which of the below methods? MCQ wait() notify()
Carefully read the question and answer
accordingly.
Which of these is not valid method in Thread void
CoreJava-Threads-Knowledge class MCQ void run() start()
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
Threads are small process which run in
CoreJava-Threads-Knowledge shared memory space within a process. MCQ TRUE FALSE
Carefully read the question and answer
accordingly. Statement Statement
Which of the following statements are true? 1 is TRUE 2 is TRUE
Statement1: When a thread is sleeping as a but but
result of sleep(), it releases its locks. Statement Statement
Statement2: The Object.wait() method can be 2 is 1 is
CoreJava-Threads-Knowledge invoked only from a synchronized context. MCQ FALSE. FALSE.

Carefully read the question and answer


accordingly.
Which two statements are true?
1.It is possible for more than two threads to
deadlock at once.
2.The JVM implementation guarantees that
multiple threads cannot enter into a
deadlocked state.
3.Deadlocked threads release once their
sleep() method's sleep duration has expired.
4.If a piece of code is capable of deadlocking,
you cannot eliminate the possibility of
deadlocking by inserting
CoreJava-Threads-Knowledge invocations of Thread.yield(). MCQ 1&2 1&3

Carefully read the question and answer


accordingly.
public class TestDemo implements Runnable
{
public void run()
{
System.out.print("Runner");
}
public static void main(String[] args)
{ You
Thread t = new Thread(new TestDemo()); cannot
t.run(); call run()
t.run(); method An
t.start(); using exception
} Thread is thrown
} class at
CoreJava-Threads-Knowledge What will be the result? MCQ object. runtime.
Carefully read the question and answer
accordingly.
class Background implements Runnable{
int i = 0; It will It will
public int run(){ compile compile
while (true) { and the and
i++; run calling
System.out.println("i="+i); method start will
} will print print out
return 1; out the the
} increasing increasing
CoreJava-Threads-Knowledge }//End class MCQ value of i. value of i.

Carefully read the question and answer


accordingly.
CoreJava-Threads-Knowledge Java provides ____ ways to create Threads. MCQ One Two

Carefully read the question and answer


accordingly.
As per the below code find which statements
are true.
public class Test {
public static void main(String[] args) {
Line 1: ArrayList<String> myList=new
List<String>();
Line 2: String string = new String();
Line 3: myList.add("string"); Line 2
Line 4: int index = myList.indexOf("string"); Line 1 has run
System.out.println(index); has time
} compilatio exception
CoreJava-Collections and util } MCA n error s
Carefully read the question and answer
accordingly.
CoreJava-Collections and util The ArrayList<String> is immutable. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
CoreJava-Collections and util Map is the super class of Dictionary class? MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Method keySet() in Map returns a set view of
the keys contained in that map.
CoreJava-Collections and util State True or False. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
CoreJava-Collections and util Is "Array" a subclass of "Collection" ? MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class Compare
{
public static void main(String[]args)
{
String s=new String("abc");
String s1=new String("abc");
System.out.println(s.compareTo(s1));
}
CoreJava-Collections and util } MCQ True False
Carefully read the question and answer
accordingly.
The LinkedList class supports two
CoreJava-Collections and util constructors. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Consider the following statements about the
Map type Objects:
Statement A: Changes made in the set view
returned by keySet() will be reflected in the
original map. Statement
Statement B: All Map implementations keep Both A is true
the keys sorted. Statement and
Which of the following option is true regarding s A and B Statement
CoreJava-Collections and util the above statements? MCQ are true B is false
Carefully read the question and answer
accordingly.
what is the way to iterate over the elements of list
CoreJava-Collections and util a Map MCA for loop Iterator

Creates a
Date
object
Carefully read the question and answer Creates a with '01-
accordingly. Date 01-1970
Consider the following partial code: object 12:00:00
java.util.Date date = new java.util.Date(); with 0 as AM' as
Which of the following statement is true default default
CoreJava-Collections and util regarding the above partial code? MCQ value value
Carefully read the question and answer
accordingly.
Consider the following list of code:
A) Iterator iterator =
hashMap.keySet().iterator();
B) Iterator iterator = hashMap.iterator();
C) Iterator iterator =
hashMap.keyMap().iterator();
D) Iterator iterator =
hashMap.entrySet().iterator();
E) Iterator iterator =
hashMap.entrySet.iterator();
Assume that hashMap is an instance of
HashMap type collection implementation.
Which of the following option gives the correct
partial code about getting an Iterator to the
CoreJava-Collections and util HashMap entries? MCQ A B

Carefully read the question and answer


accordingly.
CoreJava-Collections and util What is the return type of next() in Iterator? MCQ boolean void
Carefully read the question and answer
accordingly.
foreach loop is the only option to iterate over
CoreJava-Collections and util a Map MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Which of the following are not List
implementations?
1.Vector
2.Hashtable
3.LinkedList
CoreJava-Collections and util 4.Properties MCQ 1&2 1&3

Carefully read the question and answer


accordingly.
Consider the following Statements:
Statement A: The Iterator interface declares
only two methods: hasMoreElements and
nextElement. Statement
Statement B: The ListIterator interface Both the A is true
extends both the List and Iterator interfaces. Statement and
Which of the following option is correct s A and B Statement
CoreJava-Collections and util regarding above given statements? MCQ are true B is false
Carefully read the question and answer
accordingly.
State TRUE or FALSE.
line 1: public class Test {
line 2: public static void main(String[] args) {
line 3: Queue queue = new LinkedList();
line 4: queue.add("Hello");
line 5: queue.add("World");
line 6: List list = new ArrayList(queue);
line 7: System.out.println(list); }
line 8: }
Above code will give run time error at line
CoreJava-Collections and util number 3. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Iterator i= new
HashMap().entrySet().iterator();
CoreJava-Collections and util is this correct declaration MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Iterator is having previous() method.
CoreJava-Collections and util State True or False. MCQ FALSE TRUE

Carefully read the question and answer


accordingly.
List<Integer> newList=new
ArrayList<integer>(); will Above statement
create a new object of Array list
CoreJava-Collections and util successfully ? MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which collection class allows you to associate java.utill. java.util.A
CoreJava-Collections and util its elements with key values MCA Map rrayList
Carefully read the question and answer
accordingly.
Under java.util package we have
"Collections" as Class and "Collection" as
CoreJava-Collections and util paInterface MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
The add method of Set returns false if you try
CoreJava-Collections and util pato add a duplicate element. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Is this true or false. Map interface is derived
CoreJava-Collections and util pafrom the Collection interface. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
LinkedList represents a collection that does
CoreJava-Collections and util panot allow duplicate elements. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
What is the data type of m in the following
code?
import java.util.*;
public class set1
{
public static void main(String [] args)
{
Set s=new HashSet();
s.add(20);
s.add("abc");
for( _____ m:s)
System.out.println(m);
}
CoreJava-Collections and util pa} MCQ int String
Carefully read the question and answer
accordingly.
Which of these interface(s) are part of Java’s
CoreJava-Collections and util pacore collection framework? MCA List Set
Carefully read the question and answer
accordingly.
When comparable interface is used which comparat
CoreJava-Collections and util pamethod should be overridden? MCQ or compare
Carefully read the question and answer
accordingly.
TreeSet uses which two interfaces to sort the Serializab
CoreJava-Collections and util padata MCA le SortTable

The
elements
in the The
collection elements
are in the
accessed collection
Carefully read the question and answer using a are
accordingly. non- guarantee
Which statement are true for the class unique d to be
CoreJava-Collections and util paHashSet? MCA key. unique
Carefully read the question and answer
accordingly.
Enumeration is having remove() method.
CoreJava-Collections and util paState True or False. MCQ FALSE TRUE
Carefully read the question and answer
accordingly.
Consider the following code:
01 import java.util.Set;
02 import java.util.TreeSet;
03
04 class TestSet {
05 public static void main(String[] args) {
06 Set set = new TreeSet<String>();
07 set.add("Green World");
08 set.add(1); Prints the
09 set.add("Green Peace"); output
10 System.out.println(set); [Green
11 } World, 1, Compilati
12 } Green on error
Which of the following option gives the output Peace] at at line no
CoreJava-Collections and util pafor the above code? MCQ line no 9 8

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class collection1{
public static void main(String[]args){
Collection c=new ArrayList();
c.add(10);
c.add("abc");
Collection l=new HashSet();
l.add(20);
l.add("abc");
l.add(30);
c.addAll(l);
c.removeAll(l);
System.out.println( c );
}
CoreJava-Collections and util pa} MCQ [10,abc] [10]
Carefully read the question and answer
accordingly.
Which of these are interfaces in the collection
CoreJava-Collections and util paframework MCA Hash Map Array List

The
Iterator The
interface ListIterato
declares r interface
only three extends
methods: both the
Carefully read the question and answer hasNext, List and
accordingly. next and Iterator
CoreJava-Collections and util paWhich of the following are true statements? MCA remove. interfaces
All
All implemen
Carefully read the question and answer implemen tations
accordingly. tations support
which are the Basic features of are having
implementations of interfaces in Collections unsynchr null
CoreJava-Collections and util paFramework in java? MCA onized elements.

Carefully read the question and answer


accordingly.
Which of the following are synchronized?
1.Hashtable
2.Hashmap
3.Vector
CoreJava-Collections and util pa4.ArrayList MCQ 1&2 1&3

Carefully read the question and answer


accordingly.
What will be the output for following code?
import java.util.*;
public class StringTokens
{
public static void main(String[]args)
{
String s="India is a\n developing country";
StringTokenizer o=new StringTokenizer(s);
System.out.println(o.countTokens());
}
CoreJava-Strings, String Buffer } MCQ 4 5
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
StringBuilder is not thread-safe unlike
CoreJava-Strings, String Buffer StringBuffer MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class StringCompare{
public static void main(String[]args){
if("string"=="string")
System.out.println("both strings are equal");
else
System.out.println("both strings are not both
equal"); both strings
} strings are not
CoreJava-Strings, String Buffer } MCQ are equal equal
Carefully read the question and answer
accordingly.
endsWith() member methods of String class
creates new String object. State True or
CoreJava-Strings, String Buffer False MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class CompareStrings{
public static void main(String[]args){
String a=new String("string");
String s=new String("string");
if(a==s)
System.out.println("both strings are equal");
else
System.out.println("both strings are not both
equal"); both strings
} strings are not
CoreJava-Strings, String Buffer } MCQ are equal equal
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
String s = new String(); is valid statement in
CoreJava-Strings, String Buffer java MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What is the output of below code:
package p1;
public class Hackathon {
public static void main(String[] args) {
String x = "Java";
x.concat(" Rules!");
System.out.println("x = " + x);
} x = Java
CoreJava-Strings, String Buffer } MCQ Rules x = Java
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
StringTokenizer implements the Enumeration
CoreJava-Strings, String Buffer interface MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
State whether TRUE or FALSE.
The APIS of StringBuffer are synchronized
CoreJava-Strings, String Buffer unlike that of StringBuilder MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
What is the output of below code:
package p1;
public class Hackathon {
public static void main(String[] args) {
String x = "Java";
x.toUpperCase();
System.out.println("x = " + x);
}
CoreJava-Strings, String Buffer } MCQ x = JAVA x=""

Carefully read the question and answer


accordingly.
Consider the following code snippet:
String thought = "Green";
StringBuffer bufferedThought = new
StringBuffer(thought);
String secondThought =
bufferedThought.toString();
System.out.println(thought ==
secondThought);
Which of the following option gives the output
CoreJava-Strings, String Buffer of the above code snippet? MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Choose the correct option.
Statement I: StringBuilder offers faster
performance than StringBuffer Statement
Statement II: All the methods available on Statement I is TRUE
StringBuffer are also available on I & II are & II is
CoreJava-Strings, String Buffer StringBuilder MCQ TRUE FALSE
Carefully read the question and answer
accordingly. Comparin Searching
CoreJava-Strings, String Buffer String class contains API used for MCQ g strings strings

Carefully read the question and answer


accordingly.
Choose the correct option.
Statement I: StringBuffer is efficient than “+”
concatenation Statement
Statement II: Using API’s in StringBuffer the Statement I is TRUE
content and length of String can be changed I & II are & II is
CoreJava-Strings, String Buffer which intern creates new object. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
State whether TRUE or FALSE.
String class do not provides a method which
is used to compare two strings
CoreJava-Strings, String Buffer lexicographically. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class CompareStrings{
public static void main(String[]args){
if(" string ".trim()=="string")
System.out.println("both strings are equal");
else
System.out.println("both strings are not both
equal"); both strings
} strings are not
CoreJava-Strings, String Buffer } MCQ are equal equal

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class StringBuffer1
{
public static void main(String[]args)
{
StringBuffer s1=new
StringBuffer("welcome");
StringBuffer s2=new
StringBuffer("welcome");
System.out.println(s1.equals(s2));
System.out.println(s1.equals(s1));
}
CoreJava-Strings, String Buffer } MCQ true false false true

Carefully read the question and answer


accordingly.
What will be the output for following code?
import java.io.*;
public class Exception1
{
public static void main(String[]args)
{
System.out.println("A");

try
{
}
catch(IOException t)
{
System.out.println("B");
}

System.out.println("C");
} Compile
CoreJava-Exception Handling-Ap} MCQ time error A
Carefully read the question and answer
accordingly.
What will be the output of the program?
public class Test {
public static void aMethod() throws Exception
{
try {
throw new Exception();
} finally {
System.out.print("finally");
}
}
public static void main(String args[]) {
try {
aMethod();
} catch (Exception e) {
System.out.print("exception ");
}
System.out.print("finished"); /* Line 24 */
} exception Compilati
CoreJava-Exception Handling-Ap} MCQ finished on fails

Carefully read the question and answer


accordingly.
At Point X in below code, which code is
necessary to make the code compile?
public class Test
{
class TestException extends Exception {}
public void runTest() throws TestException
{}
public void test() /* Point X */
{
runTest(); throws catch
} RuntimeE ( Exceptio
CoreJava-Exception Handling-Ap} MCQ xception n e )

Carefully read the question and answer


accordingly.
If you put a finally block after a try and its An
associated catch blocks, then once execution exception
enters the try block, the code in that finally arising in The use
block will definitely be executed except in the finally of
some circumstances.select the correct block System.e
CoreJava-Exception Handling-Apcircumstance from given options: MCA itself xit()
Carefully read the question and answer
accordingly.
What will be the output of the below code?
public class Test {
public static void main(String[] args) {
int a = 5, b = 0, c = 0;
String s = new String();
try {
System.out.print("hello ");
System.out.print(s.charAt(0));
c = a / b;
} catch (ArithmeticException ae) {
System.out.print(" Math problem occur");
} catch (StringIndexOutOfBoundsException
se) {
System.out.print(" string problem occur");
} catch (Exception e) {
System.out.print(" problem occurs");
} finally { hello 0
System.out.print(" stopped"); Math
} problem
} hello 0 occur
CoreJava-Exception Handling-Ap} MCQ stopped stopped

Carefully read the question and answer


accordingly.
Within try block if System.exit(0) is called then
also finally block is going to be executed.
CoreJava-Exception Handling-ApState True or False. MCQ FALSE TRUE

Carefully read the question and answer


accordingly.
Which of the following are checked
exceptions?
1.ClassNotFoundException
2.InterruptedException
3.NullPointerException
CoreJava-Exception Handling-Ap4.ArrayIndexOutOfBoundsException MCQ 1&2 1&3
Carefully read the question and answer
accordingly.
which of these are the subclass of Exception IOExcepti Throwabl
CoreJava-Exception Handling-Apclass MCA on e
Runtime
exception
s need
not be
explicitly Runtime
caught in exception
try catch s include
block as it arithmetic
can occur exception
Carefully read the question and answer anywhere s, pointer
accordingly. in a exception
CoreJava-Exception Handling-Apwhat are true for RuntimeException MCA program. s

Carefully read the question and answer


accordingly.
What will be the output of following code?
try
{
System.out.println("Executing try");
}
System.out.println("After try"); Executing
catch (Exception ex) try After Executing
{ try try
System.out.println("Executing catch"); Executing Runtime
CoreJava-Exception Handling-Ap} MCQ catch Exception

Carefully read the question and answer


accordingly.
Consider the following code:
class MyException extends Throwable { }
public class TestThrowable {
public static void main(String args[]) {
try {
test();
} catch(Throwable ie) {
System.out.println("Exception");
}
} Compiler
time error
static void test() throws Throwable { User
throw new MyException(); defined
} exception
} s should
Which of the following option gives the output Prints extend
CoreJava-Exception Handling-Apfor the above code? MCQ Exception Exception

Array
Index Out
Carefully read the question and answer Class Of
accordingly. Cast Bounds
CoreJava-Exception Handling-Apwhich are the Unchecked exceptions MCA Exception Exception
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class Exception1
{
public static void main(String[]args)
{
System.out.println("A");
try
{
System.exit(0);
}catch(Exception e)
{
System.out.println("B");
}
System.out.println("C");
}
}
CoreJava-Exception Handling-Ap} MCQ A,C A

NoClassD
efFoundE
rror
means
that the
class was
A found by
ClassNot the
FoundExc ClassLoa
eption is der
thrown however
when the when
reported trying to
class is load the
not found class, it
by the ran into
ClassLoa an error
Carefully read the question and answer der in the reading
accordingly. CLASSP the class
CoreJava-Exception Handling-ApWhich is/are true among given statements MCA ATH. definition.
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class Exe3
{
public static void main(String[]args)
{
try
{
int i=10;
int j=i/0;
return;
}catch(Exception e)
{
System.out.println("welcome");
}
System.out.println("error");
}
}
1.welcome
2.error
CoreJava-Exception Handling-Ap3.compilation error MCQ 1&2 1&2&3

if
exception
occurs,
Try block control
always switches
needed a to
Carefully read the question and answer catch following
accordingly. block first Catch
CoreJava-Exception Handling-Apwhich are true for try block MCA followed block
Carefully read the question and answer
accordingly.
What will be the output of following code?
public class Exception1{
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i/j > 1)
i++;
} catch(ArithmeticException e) {
System.out.println(0);
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println(1);
} catch(Exception e) {
System.out.println(2);
}
finally {
System.out.println(3);
}
System.out.println(4);
}
}
1.0
2.1
3.3
CoreJava-Exception Handling-Ap4.4. MCQ 1&2 1&2&3

Carefully read the question and answer


accordingly.
Consider the following code:
1 public class FinallyCatch {
2 public static void main(String args[]) { Shows Shows
3 try { unhandle unhandle
4 throw new java.io.IOException(); d d
5 } exception exception
6 } type type
7 } IOExcepti IOExcepti
Which of the following is true regarding the on at line on at line
CoreJava-Exception Handling-Apabove code? MCQ number 4 number 5
Carefully read the question and answer
accordingly. FileNotFo
Which of the following exception is not IOExcepti undExcep
CoreJava-Exception Handling-C mandatory to be handled in code? MCQ on tion
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class Exception1{
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i/j > 1)
i++;
} catch(Exception e) {
System.out.println(2);
} catch(ArithmeticException e) {
System.out.println(0);
}
finally {
System.out.println(3);
}
}
CoreJava-Exception Handling-C } MCQ 2
Carefully read the question and answer
accordingly.
select true or false . Statement : Throwable is
the super class of all exceptional type
CoreJava-Exception Handling-C classes. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
try and throws keywords are used to manually
CoreJava-Exception Handling-C throw an exception? MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
RuntimeException is the superclass of those
exceptions that can be thrown during the
CoreJava-Exception Handling-C normal operation of the Java Virtual Machine. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Which of the following statement is true
regarding implementing user defined
exception mechanisms? Statement
Statement A: It is valid to derive a class from Both A is true
java.lang.Exception Statement and
Statement B: It is valid to derive a class from s A and B Statement
CoreJava-Exception Handling-C java.lang.RuntimeException MCQ are true B is false
An
exception
which is
not
handled
by a catch
block will A catch
be block can
handled have
Carefully read the question and answer by another
accordingly. subseque try block
Which of the following statement is true nt catch nested
CoreJava-Exception Handling-C regarding try-catch-finally? MCQ blocks inside
Carefully read the question and answer
accordingly.
Which of these keywords are a part of
CoreJava-Exception Handling-C exception handling? MCA try final
Carefully read the question and answer
accordingly.
CoreJava-Exception Handling-C Error is the sub class of Throwable MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which of these keywords is used to explicitly
CoreJava-Exception Handling-C throw an exception? MCQ try finally
Carefully read the question and answer
accordingly.
is it valid to place some code in between try
CoreJava-Exception Handling-C and catch blocks. MCQ TRUE FALSE

A
checked
exception
is a error and
subclass checked
Carefully read the question and answer of exception
accordingly. throwable s are
CoreJava-Exception Handling-C which are correct for checked exceptions MCA class same.
Carefully read the question and answer
accordingly.
Try can be followed with either catch or
finally.
CoreJava-Exception Handling-C State True or False. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which is the super class for Exception and Throwabl
CoreJava-Exception Handling-C Error? MCQ e throws
Carefully read the question and answer
accordingly.
The finally block always executes when the
try block exits.
CoreJava-Exception Handling-C State True or False. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Select two runtime exceptions.
1.SQLException
2.NullPointerException
3.FileNotFoundException
4.ArrayIndexOutOfBoundsException
CoreJava-Exception Handling-C 5.IOException MCQ 1&2 1&5
Carefully read the question and answer
accordingly.
Propagating exceptions across modules is not
possible without throw and throws keyword.
CoreJava-Exception Handling-C State True or False. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class Exe3 {
public static void main(String[]args){
try{
int i=10;
int j=i/0;
return;
}catch(Exception e){
try{
System.out.println("welcome");
return;
}catch(Exception e1){
}
System.out.println("error");
}
}
CoreJava-Exception Handling-C } MCQ welcome error
Carefully read the question and answer
accordingly.
What will be the output for following code?
class super5{
void Get()throws Exception{
System.out.println("IOException");
}
}
public class Exception2 extends super5{
public static void main(String[]args){
super5 o=new super5();
try{
o.Get();
}catch(IOException e){
}
} IOExcepti compilatio
CoreJava-Exception Handling-C } MCQ on n error
Carefully read the question and answer
accordingly.
Serialization is representing object in a
CoreJava-I/O Operations in Jav sequence of bytes. State True or False. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Serialization is JVM independent.State True
CoreJava-I/O Operations in Jav or False. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
Statement 1:static variables can be serialized statement statement
Statement2:transient variables cannot be 1:true 1:false
serialized statement statement
CoreJava-I/O Operations in Jav which of the following is true? MCQ 2:true 2:true
setting up
BufferedO
utputStre
aman , an
applicatio
n can
write
bytes to
the
underlyin
g output
stream
without
necessaril
y causing
BufferedO a call to
utputStre the
am class underlyin
Carefully read the question and answer is a g system
accordingly. member for each
select the correct statements about of Java.io byte
CoreJava-I/O Operations in Jav BufferedOutputStream class MCA package written.
Carefully read the question and answer
accordingly.
DataInputStream is not necessarily safe for
CoreJava-I/O Operations in Jav multithreaded access. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which of the following is a marker interface Serializab
CoreJava-I/O Operations in Jav used for object serialization? MCQ Runnable le
Carefully read the question and answer
accordingly.
InputStream is the class used for stream of
characters.
CoreJava-I/O Operations in Jav State True or False. MCQ FALSE TRUE
Carefully read the question and answer
accordingly.
BufferedWriter constructor CAN ACCEPT
Filewriter Object as a parameter.
CoreJava-I/O Operations in Jav State True or False. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which of these class are the member class of ObjectInp StringRea
CoreJava-I/O Operations in Jav java.io package? MCA ut der
Carefully read the question and answer
accordingly.
Which of these interface is not a member of ObjectInp
CoreJava-I/O Operations in Jav java.io package? MCQ DataInput ut
Carefully read the question and answer
accordingly.
Which of the following are abstract classes?
1.Reader
2.InputStreamReader
3.InputStream
CoreJava-I/O Operations in Jav 4.OutputStream MCQ 1&2 1&2&3

Carefully read the question and answer


accordingly.
An ObjectInputStream deserializes objects
previously written using an
ObjectOutputStream.
CoreJava-I/O Operations in Jav State True or False. MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
The InputStream.close() method closes this
CoreJava-I/O Operations in Jav stream and releases all system resources MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
State TRUE or FALSE.
getParent() gives the parent directory of the
file and isFile() Tests whether the file denoted
by the given abstract pathname is a normal
CoreJava-I/O Operations in Jav file. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
InputStreamReader is sub class of
CoreJava-I/O Operations in Jav FilterReader. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
isFile() returns true if called on a file or when
CoreJava-I/O Operations in Jav called on a directory MCQ TRUE FALSE

Carefully read the question and answer


accordingly.
What is the output of this program?
1. import java.io.*;
2. class files {
3. public static void main(String args[]) {
4. File obj = new File("/java/system");
5. System.out.print(obj.getName());
6. } java/ /java/
CoreJava-I/O Operations in Jav 7. } MCQ system system
Carefully read the question and answer
accordingly.
Which of these class are related to input and
CoreJava-I/O Operations in Jav output stream in terms of functioning? MCA File Writer
Carefully read the question and answer
accordingly.
The ______ statement is used inside the
CoreJava-Control Structures_W switch to terminate a Statement sequence MCQ break Jump
Carefully read the question and answer
accordingly.
The result of 10.987+”30.765” is 10.98730. 10.9873.7
CoreJava-Control Structures_W _________________. MCQ 765 65
Carefully read the question and answer
accordingly. by
CoreJava-Control Structures_W Data can be passed to the function ____ MCQ by value reference
Carefully read the question and answer
accordingly.
_____________ is a multi way branch
CoreJava-Control Structures_W statement MCQ switch continue
Carefully read the question and answer
accordingly.
Which of the following is a loop construct that
CoreJava-Control Structures_W will always be executed once? MCQ switch for

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class While {
static int i;
public static void main(String[]args){
System.out.println(i);
while(i<=5){
i++;
}
System.out.println(i);
} compilatio
CoreJava-Control Structures_W } MCQ n error 0,6

The
number of
Carefully read the question and answer bytes is
accordingly. compiler
What is the number of bytes used by Java dependen
CoreJava-Control Structures_W primitive long MCQ t 2
Carefully read the question and answer
accordingly.
We can use Wrapper objects of type int,
short, char in switch case.
CoreJava-Control Structures_W State True or False. MCQ TRUE FALSE

Carefully read the question and answer


accordingly. The
What happens when the following code is The class number 1
compiled and run. Select the one correct compiles gets
answer. and runs, printed
for(int i = 1; i < 3; i++) but does with
for(int j = 3; j >= 1; j--) not print Assertion
CoreJava-Control Structures_W assert i!=j : i; MCQ anything. Error
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class WrapperClass12
{
public static void main(String[]args)
{
Boolean b=true;
boolean a=Boolean.parseBoolean("tRUE");
System.out.println(b==a);
}
CoreJava-Control Structures_W } MCQ True False

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class WrapperClass1 {
public static void main(String[]args){
String s="10Bangalore";
int i=Integer.parseInt(s);
System.out.println(i);
} 10Bangal
CoreJava-Control Structures_W } MCQ ore 10

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class While {
public static void main(String[]args){
int a='A';
int i=a+32;
while(a<='Z'){
a++;
}
System.out.println(i);
System.out.println(a);
}
CoreJava-Control Structures_W } MCQ A,Z a,z

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class WrapperClass1 {
public static void main(String[]args){
Integer i=new Integer(10);
Integer j=new Integer(10);
System.out.println(i==j);
}
CoreJava-Control Structures_W } MCQ True False
Carefully read the question and answer
accordingly.
What will be the output for following code?
public class Wrapper2 {
public static void main(String[]args){
Byte b=1;
Byte a=2;
System.out.println(a+b); compiles
} and print compilatio
CoreJava-Control Structures_W } MCQ 3 n error

Carefully read the question and answer


accordingly.
What will be the output for following code?
public class Wrapper11
{
public static void main(String[]args)
{
Long l=100;
System.out.println(l);
} Compilati
CoreJava-Control Structures_W } MCQ 100 on error

Carefully read the question and answer


accordingly.
What will be the output of below code?
public class Test {
public static void main(String[] args) {
int i = 1;
Integer I = new Integer(i);
method(i);
method(I);
}
static void method(Integer I) {
System.out.print(" Wrapper");
}
static void method(int i) {
System.out.print(" Primitive");
} Primitive
CoreJava-Control Structures_W } MCQ Wrapper Wrapper

Carefully read the question and answer


accordingly.
What is the value of variable "I" after
execution of following code?
public class Evaluate
{
public static void main(String[]args)
{
int i=10;
if(((i++)>12)&&(++i<15))
System.out.println(i);
else
System.out.println(i);
}
CoreJava-Control Structures_W } MCQ 10 11
Carefully read the question and answer
accordingly.
Each case in switch statement should end
CoreJava-Control Structures_W with ________ statement MCQ default break
Carefully read the question and answer
accordingly.
Type 1 & Type 3 driver types are not vendor
specific implementation of Java driver. State
CoreJava-JDBC-Knowledge True or False MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
The JDBC-ODBC Bridge driver translates the
JDBC API to the ODBC API and used with JDBC ODBC
CoreJava-JDBC-Knowledge which of the following: MCQ drivers drivers
Carefully read the question and answer
accordingly. ODBC ODBC
A Java program cannot directly communicate written in written in
with an ODBC driver because of which of the C Java
CoreJava-JDBC-Knowledge following: MCQ language language

Carefully read the question and answer


accordingly.
Which statements about JDBC are true?
1.JDBC has 5 types of Drivers
2.JDBC stands for Java DataBase
Connectivity
3.JDBC is an API to access relational
databases, spreadsheets and flat files
4.JDBC is an API to bridge the object-
relational mismatch between OO programs
CoreJava-JDBC-Knowledge and relational databases MCQ 1&2 3&4
Carefully read the question and answer
accordingly.
Which type of driver converts JDBC calls into
the network protocol used by the database Type 1 Type 2
CoreJava-JDBC-Knowledge management system directly? MCQ driver driver

Carefully read the question and answer


accordingly. Paramete
Which type of Statement can execute Prepared rizedState
CoreJava-JDBC-Knowledge parameterized queries? MCQ Statement ment
Carefully read the question and answer
accordingly.
Connection object can be initialized using putConne setConne
CoreJava-JDBC-Knowledge which method of the Driver Manager class? MCQ ction() ction()
Carefully read the question and answer
accordingly.
Which of the following is true with respect to
code given below?
import java.sql.*;
public class OracleDemo
{
public static void main(String [] args) throws
SQLException,ClassNotFoundException
{

Class.forName("oracle.jdbc.driver.OracleDrive
r");
Connection
con=DriverManager.getConnection("jdbc:orac
le:thin:@PC188681:1521:training","scott","tig
er");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT *
FROM Person"); The code The code
while(rs.next()) will not will
{ compile display all
System.out.println(rs.getString("column1")); as no try values in
} catch column
} block named
CoreJava-JDBC-Knowledge } MCQ specified column1

Carefully read the question and answer


accordingly.
If your JDBC Connection is in auto-commit
mode, which it is by default, then every SQL
statement is committed to the database upon
CoreJava-JDBC-Knowledge its completion. State True or False. MCQ TRUE FALSE

Call Call
method method
execute() executePr
Carefully read the question and answer on a ocedure()
accordingly. CallableSt on a
How can you execute a stored procedure in atement Statement
CoreJava-JDBC-Knowledge the database? MCQ object object
Carefully read the question and answer
accordingly.
Consider the following statements:
Statement A: The PreparedStatement object
enables you to execute parameterized
queries. Both Statement
Statement B: The SQL query can use the Statement A is True
placeholders which are replaced by the A and and
INPUT parameters at runtime. Statement Statement
Which of the following option is True with B are B is
CoreJava-JDBC-Knowledge respect to the above statements? MCQ True. False.

Connectio
n
cn=Driver
Manager.
getConne
Connectio ction("jdb
Carefully read the question and answer n c:odbc:My
accordingly. cn=Driver dsn",
You are using JDBC-ODBC bridge driver to Manager. "usernam
establish a connection with a database. You getConne e",
have created a DSN Mydsn. Which statement ction("jdb "passwor
CoreJava-JDBC-Knowledge will you use to connect to the database? MCQ c:odbc"); d");
Carefully read the question and answer
accordingly.
Which of the following listed option gives the
valid type of object to store a date and time java.util.D java.sql.D
CoreJava-JDBC-Knowledge combination using JDBC API? MCQ ate ate

Carefully read the question and answer


accordingly.
Which method executes an SQL statement executeU executeQ
CoreJava-JDBC-Knowledge that may return multiple results? MCQ pdate() uery()

Carefully read the question and answer


accordingly.
Which package contains classes that help in
connecting to a database, sending SQL
statements to the database, and processing connectio
CoreJava-JDBC-Knowledge the query results MCQ n.sql db.sql
Carefully read the question and answer
accordingly.
Which method sets the query parameters of putString( insertStrin
CoreJava-JDBC-Knowledge the PreparedStatement Object? MCQ ) g()
DDL
statement
s are
treated as
normal
SQL
statement
s, and are
executed
by calling To
the execute
execute() DDL
method statement
on a s, you
Statement have to
(or a sub install
Carefully read the question and answer interface additional
accordingly. thereof) support
CoreJava-JDBC-Knowledge What is correct about DDL statements? MCQ object files
Carefully read the question and answer
accordingly.
What is the state of the parameters of the
PreparedStatement object when the user
CoreJava-JDBC-Knowledge clicks on the Query button? MCQ initialized started
Carefully read the question and answer
accordingly.
executeUpdate() & execute() are valid
methods that can be used for executing DDL
CoreJava-JDBC-Knowledge statements. State True or False MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which object provides you with methods to Parametri
CoreJava-JDBC-Knowledge access data from the table? MCQ ResultSet zed
Carefully read the question and answer
accordingly.
The method Class.forName() is a part of
CoreJava-JDBC-Knowledge JDBC API. State True or False. MCQ TRUE FALSE
Carefully read the question and answer
accordingly.
Which object allows you to execute Parametri
CoreJava-JDBC-Knowledge parametrized queries? MCQ ResultSet zed
Carefully read the question and answer
accordingly.
Which method executes a simple query and executeU executeQ
CoreJava-JDBC-Knowledge returns a single Result Set object? MCQ pdate() uery()
java.jdbc
Carefully read the question and answer java.jdbc and
accordingly. and java.jdbc.
CoreJava-JDBC-Knowledge Which packages contain the JDBC classes? MCQ javax.jdbc sql
select select
ename ,s ename ,s
al ,deptno al ,deptno
from emp from emp
a where a where
a.sal < a.sal >
(select (select
Carefully read the question and answer avg(sal) avg(sal)
accordingly. from emp from emp
You are writing a query to select all b where b where
employees whose salary is less than the a.deptno a.deptno
average of all the employees' salaries in the = =
same department. b.deptno) b.deptno)
Which query will help you to achieve your order by order by
Oracle-SQL Expressions/SQL Fun
goal? MCQ deptno; deptno;

Carefully read the question and answer


accordingly.
With SQL, how can you find the range for the
price between 2000 and 8000 in item table?
1.Select * from item where price between
2000 and 8000.
2.Select * from item where price >=2000 and
price <=8000.
3.Select * from item where price <>2000 and
price !=8000.
4.Select * from item where price >2000 and
Oracle-SQL Expressions/SQL Fun
price <8000. MCQ 1&2 3&4

Carefully read the question and answer


accordingly.
Examine the table structure of Employee
Ename Ecode Dept
John 1 Sal
Smith 3 Mar
Max 2 Sal
Joe 4 Mar Sales
Laura 5 Dep Marketing
What will be the output of below query ? Sales
select Query Marketing
decode(Ecode,5,'Department',4,'Marketing',3,’ contains Departme
Oracle-SQL Expressions/SQL Fun
Marketing’,’Sales’) as result from Employee; MCQ error nt

Carefully read the question and answer


accordingly. Query
What will be the output of the query? contains
Oracle-SQL Expressions/SQL Fun
Select trim(0 from '00003443500') from dual? MCQ error 34435
Carefully read the question and answer adds 10 adds 10
accordingly. seconds minutes
What will be the output of the below query? to the to the
select current current
to_CHAR(sysdate+(10/1400),'HH:MI:SS') Timestam Timestam
Oracle-SQL Expressions/SQL Fun
from dual; MCQ p p

Carefully read the question and answer


accordingly.
Which of the following integrity rules of SQL
states that if a relational table has a foreign
key, then every value of the foreign key must
either be null or match the values in the Referenti
relational table in which that foreign key is a al Domain
Oracle-SQL Expressions/SQL Fun
primary key? MCQ Integrity Integrity

Carefully read the question and answer


accordingly.
What will be the result of the following code?
Oracle-SQL Expressions/SQL Fun
SELECT (2+3*4/2–5) FROM dual; MCQ 3 2

Carefully read the question and answer


accordingly. Query
What will be the output of the below query? contains
Oracle-SQL Expressions/SQL Fun
select instr('My SQL World','a') from dual; MCQ error Prints 0

Carefully read the question and answer All


accordingly. supplier
What will be the output of the below query? Query will record will
SELECT * FROM suppliers generate be
Oracle-SQL Expressions/SQL Fun
WHERE supplier_name LIKE '!%' escape '!'; MCQ an error displayed
sub class
show
method
super
class
show Compilati
method on Error 1 0 0 0 TEXT

1 0 TEXT

public,frie final,prote private,ab


nd cted stract 0 1 0 0 0 TEXT

0 1 TEXT

Construct
or is a
special Construct
type of ors
method should be
which called
may have explicitly
return like
type. methods 1 0 0 0 TEXT
1 0 TEXT

Implemen Access
tation specifier Class 0 0 0 1 0 TEXT

III I & III 1 0 0 0 TEXT

None of
the listed
options private 0 1 0 0 TEXT
super
display class
method method
display display
method method
20 20 10 10 0 1 0 0 TEXT
None of
Compilati the listed
on error options 1 0 0 0 TEXT

Construct Destructo
or r Variable 0 0 1 0 0 TEXT

All
members Protected
of is default
abstract access
class are modifier
by default of a child
protected class 1 0 0 0 TEXT
None of
Compilati the listed
on error options 0 0 1 0 TEXT

1 0 TEXT

Polymorp
Generic hic 1 0 0 0 TEXT

2&3 3&4 2&4 0 0 0 0 1 TEXT


0 1 TEXT

20 10 10 20 0 1 0 0 TEXT

0 1 TEXT
Parent
Child Child 0 0 1 0 TEXT

public
void
aM1(){}
public
void
aM2(){}
public public
void void
bM1(){} aM1(){}
public public
void void
bM2(){} bM2(){} 0 0 1 0 TEXT
0 1 TEXT

Statement
I is Statement
FALSE & I & II are
II is TRUE FASLE 1 0 0 0 TEXT

Statement
I is Statement
FALSE & I & II are
II is TRUE FASLE 1 0 0 0 TEXT
1 0 TEXT

1 0 TEXT

2&3 1&2&4 2&4 0 0 0 1 0 TEXT

Statement
I is Statement
FALSE & I & II are
II is TRUE FASLE 1 0 0 0 TEXT
120, 120,
60,60,60 120 0 0 0 1 TEXT

None of
It will print the listed
5 options 0 1 0 0 TEXT
1 0 TEXT

1 0 TEXT
2&3 3&4 2&4 0 0 0 0 1 TEXT

0 1 TEXT
public All of the
void listed
bM2(){} options 0 0 0 1 TEXT

1 0 TEXT

1 0 TEXT
The code
will
This class compile
must also as Object
implemen class's
t the equals
hashCode method is
method overridde
as well. n. 1 0 0 0 TEXT

static abstract 1 0 0 0 TEXT

No Output
Runtime will be
Exception displayed 0 1 0 0 TEXT
DigiCam
do Runtime
Charge Error 1 0 0 0 TEXT

they're
not equal No Output
t1's an Will be
Object Displayed 0 0 1 0 TEXT

0 1 TEXT
Compile
WD 500 Error. 0 0 1 0 TEXT

1 0 TEXT

Statement
I is Statement
FALSE & I & II are
II is TRUE FASLE 1 0 0 0 TEXT
Code will
compile
but wont
print any Runtime
message Exception 1 0 0 0 TEXT

1 0 TEXT

None of
compilatio the listed
n error options 0 0 1 0 TEXT
Neither
Statement Statement
B alone s A nor B 1 0 0 0 TEXT

scope none of
resolution these 0 1 0 0 TEXT

System.o System.g
ut.gc(); c(); 0 0 0 1 TEXT

Compilati
4 on error 0 1 0 0 TEXT

print main Object 0 1 0 0 0 TEXT

throwed Integer Boolean 0 0 1 0 0 TEXT

finally access exception 0 0 0 0.5 0.5 TEXT


0 1 TEXT

13,13,0 12,13,-1 0 1 0 0 TEXT

4 2 0 0 0 1 TEXT

I->III->IV- I->II->III-
>II >IV 1 0 0 0 TEXT

1 0 TEXT

1 0 TEXT
Statement
A is false Both
and Statement
Statement s A and B
B is true are false 1 0 0 0 TEXT

line 5 line 1 0 1 0 0 TEXT

Option 1 Option 4 0 0 1 0 TEXT

Dead Blocked Stop 0 0 0 0 1 TEXT

Important
job
running in
MyThread
String in String in
run run No Output 0 0 0 0 1 TEXT
Requires
less
overhead
s
compared
Increase to None of
system multitaski the
efficiency. ng. options. 0 0 0 0 1 TEXT

The delay
between
“Start!” If “Time’s
being Over!” is
printed printed,
and you can
“Time’s be sure
Over!” will that at
be 10 least 10
seconds seconds
plus or have
minus elapsed
one tick of since
the “Start!”
system was
clock. printed. 0 0 0 1 TEXT
Synchroni
Synchroni zed Synchroni
zed abstract zed
classes classes interfaces 0.5 0.5 0 0 0 TEXT

1 0 TEXT
Non of
Runtime the
Exception options 0 1 0 0 TEXT

The code
executes
normally,
but
nothing is Compilati
printed. on fails. 1 0 0 0 TEXT

all the
notifyAll() options 0 0 0 1 TEXT

boolean
getPriority boolean
() isAlive() 0 0 1 0 TEXT

1 0 TEXT
BOTH BOTH
Statement Statement
1& 1&
Statement Statement
2 are 2 are
TRUE. FALSE. 0 1 0 0 TEXT

2&3 1&4 2&4 0 0 0 1 0 TEXT

The code
executes
The code and prints
executes "RunnerR
and prints unnerRun
"Runner". ner". 0 0 0 1 TEXT
Compilati
on will
cause an
error
because
The code while
will cause cannot
an error take a
at compile parameter
time. of true. 0 0 1 0 TEXT

Three Four 0 1 0 0 TEXT

In Line 4
null
pointer
exception Line 4
will occur has
as String neither
string error nor
contains exception
null value s. 0.5 0 0 0.5 TEXT

0 1 TEXT

0 1 TEXT

1 0 TEXT

0 1 TEXT
None of
the listed
options 0 0 1 0 TEXT

1 0 TEXT

Statement
A is false Both
and Statement
Statement s A and B
B is true are false 0 1 0 0 TEXT

foreach Iterator 0 0 0.5 0.5 TEXT

Creates a Creates a
Date Date
object object
with with
current current
date and date
time as alone as
default default
value value 0 0 1 0 TEXT
C D E 0 0 0 1 0 TEXT

Object String 0 0 1 0 TEXT

0 1 TEXT

2&3 1&4 2&4 0 0 0 0 1 TEXT

Statement
A is false Both the
and statement
Statement s A and B
B is true are false. 0 0 0 1 TEXT
0 1 TEXT

1 0 TEXT

1 0 TEXT

0 1 TEXT

java.util.D java.util.H
ictionary ashMap 0 0 0.5 0.5 TEXT

1 0 TEXT

1 0 TEXT

0 1 TEXT

0 1 TEXT
Object set1 0 0 1 0 TEXT

SortedQu
SortedList eue 0.5 0.5 0 0 TEXT

compareT compare
o With 0 0 1 0 TEXT

Compara
SortedSet ble 0 0 0.5 0.5 TEXT

The
elements
in the
collection
are HashSet
accessed allows at
using a most one
unique null
key. element 0 0.5 0 0.5 TEXT

1 0 TEXT
Prints the
output
[Green
World,
Throws Green
Runtime Peace] at
Exception line no 9 0 0 1 0 TEXT

Compilati
on error [abc] 0 1 0 0 TEXT

Sorted
Collection Map 0 0 0.5 0.5 TEXT

The The
ListIterato ListIterato
r interface r interface
provides provides
the ability forward
to and
determine backward
its iteration
position in capabilitie
the List. s. 0.33 0 0.33 0.33 TEXT
all
implemen
All tations
implemen are
tations immutabl
are e and
serializabl supports
e and duplicates
cloneable data 0.33 0.33 0.33 0 TEXT

2&3 1&4 2&4 0 1 0 0 0 TEXT

None of
the listed
6 options 0 1 0 0 TEXT

1 0 TEXT

compilatio Runtime
n error error 1 0 0 0 TEXT
0 1 TEXT

Strings
cannot be
compare
compilatio using ==
n error operator 0 1 0 0 TEXT

1 0 TEXT

x = Rules Error 0 1 0 0 TEXT

1 0 TEXT

1 0 TEXT
x = Java x="JAVA" 0 0 1 0 TEXT

0 1 TEXT

Statement
I is Statement
FALSE & I & II are
II is TRUE FASLE 1 0 0 0 TEXT

Extracting All of
strings above 0 0 0 1 TEXT

Statement
I is Statement
FALSE & I & II are
II is TRUE FASLE 0 1 0 0 TEXT

0 1 TEXT
Strings
cannot be
compare
compilatio using ==
n error operator 0 1 0 0 TEXT

true true false false 0 1 0 0 TEXT

Runtime
A,C error 1 0 0 0 TEXT
finally
exception
finally finished 0 0 0 1 TEXT

No code
is
throws necessary
Exception . 0 0 1 0 TEXT

finally
block will
be always
executed
in any The death
circumsta of the
nces. thread 0.33 0.33 0 0.33 TEXT
hello
Math
problem
occur
string
problem hello
occur string
problem problem
occurs occur
stopped stopped 0 0 0 1 TEXT

1 0 TEXT

2&3 1&4 2&4 1 0 0 0 0 TEXT

FileNotFin
RunTime dExceptio
Exception n 0.33 0 0.33 0.33 TEXT
RunTime
Exception
are the
exception
s which
forces the
programm
er to
catch
RuntimeE them
xception explicitly
is a class in try-
of I/O catch
exception block 0.5 0.5 0 0 TEXT

Compile
Time Runtime
Exception Exception 0 0 1 0 TEXT

Compile Run time


time error error
Cannot test()
use method
Throwabl does not
e to catch throw a
the Throwabl
exception e instance 1 0 0 0 TEXT

ClassNot Number
FoundExc Format
eption Exception 0.33 0.33 0 0.33 TEXT
None of
Compilati the listed
on error options 0 1 0 0 TEXT

NoClassD
efFoundE
rror is a
subClass
of
ClassNot None of
FoundExc the
eption options 0.5 0.5 0 0 TEXT
1&3 2 2&3 1 0 0 0 0 TEXT

after
switching
from try
block to
catch catch
block is block the
not control
mandate never
always come
only back to
finally try block
followed to
by try can execute
be rest of the
executed code 0 0 0.5 0.5 TEXT
1&3&4 1&2&4 2&4 0 0 1 0 0 TEXT

Demands Demands
a finally a finally
block at block at
line line
number 4 number 5 0 0 0 1 TEXT

NullPointe
SQLExce rExceptio
ption n 0 0 0 1 TEXT
compilatio
3 n error 0 0 0 1 TEXT

1 0 TEXT

0 1 TEXT

1 0 TEXT

Statement
A is false Both
and Statement
Statement s A and B
B is true are false 1 0 0 0 TEXT
Both
catch
block and
finally
block can
throw All of the
exception listed
s options 0 0 0 1 TEXT

thrown catch 0.5 0 0 0.5 TEXT

1 0 TEXT

throw throwable 0 0 1 0 TEXT

0 1 TEXT

Checked
exception
s are the
object of
the
Exception
class or All
any of its runtime
subclasse exception
s except s are
Runtime checked
Exception exception
class. s 0.5 0 0.5 0 TEXT

1 0 TEXT

RuntimeE
throw xception 1 0 0 0 TEXT
1 0 TEXT

2&3 1&4 2&4 0 0 0 0 1 TEXT

0 1 TEXT

None of
compilatio the listed
n error options 1 0 0 0 TEXT
None of
Runtime the listed
error options 0 1 0 0 TEXT

1 0 TEXT

1 0 TEXT

statement statement
1:false 1:true
statement statement
2:false 2:false 0 1 0 0 TEXT
As bytes
from the
stream
are read
or
skipped,
the
internal
buffer is
refilled as
necessary
from the
contained
input
stream,
it has many
flush() bytes at a
method time. 0.33 0.33 0.33 0 TEXT

1 0 TEXT

None of
Externaliz the listed
able options 0 1 0 0 TEXT

1 0 TEXT

1 0 TEXT

File String 0 0.5 0.5 0 TEXT

ObjectFilt
er FileFilter 0 0 1 0 TEXT
1&3&4 1&2&4 2&4 0 0 1 0 0 TEXT

1 0 TEXT

0 1 TEXT

1 0 TEXT

0 1 TEXT

0 1 TEXT

compilatio
system n error 0 0 1 0 TEXT

OutputStr
Reader eam 0 0.33 0.33 0.33 TEXT
exit goto escape 1 0 0 0 0 TEXT

Compilati
on error 10.987 1 0 0 0 TEXT
Both by
value & none of
reference these 1 0 0 0 TEXT

break label branch 1 0 0 0 0 TEXT

do ….
while While for..each 0 0 0 1 0 TEXT

6,0 0,5 0 1 0 0 TEXT

4 8 64 0 0 0 1 0 TEXT

1 0 TEXT

The The
number 2 number 3 The
gets gets program
printed printed generates
with with a
Assertion Assertion compilatio
Error Error n error. 0 1 0 0 0 TEXT
Compilati Runtime
on error Exception 1 0 0 0 TEXT

Compilati Runtime
on error Exception 0 0 0 1 TEXT

91,97 97,91 0 0 0 1 TEXT

None of
compilatio the listed
n error options 0 1 0 0 TEXT
compiles
Runtime and prints
Error 12 1 0 0 0 TEXT

code will
execute
with out runtime
printing Exception 0 1 0 0 TEXT

None Of
Wrapper the
Primitive Primitive options 1 0 0 0 0 TEXT

None of
the listed
12 options 0 1 0 0 TEXT
continue new none 0 1 0 0 0 TEXT

1 0 TEXT

Both A None of
and B the above 0 1 0 0 TEXT

ODBC ODBC
written in written in
C++ Basic
language language 1 0 0 0 TEXT

2&3 1&4 2&4 0 0 1 0 0 TEXT

Type 3 Type 4
driver driver 0 0 0 1 TEXT

All kinds
of
Statement
s (i.e.
which
implemen
Paramete t a sub
rizedState interface
ment and of
CallableSt Statement
atement ) 1 0 0 0 TEXT

Connectio getConne
n() tion() 0 0 0 1 TEXT
"SELECT
* FROM
Person"
Class.for query
Name must be
must be passed as
mentione parameter
d after to
Connectio con.creat
n eStateme
statement nt() 0 1 0 0 TEXT

1 0 TEXT

Call
method Call
execute() method
on a run() on a
StoredPro Procedur
cedure eComma
object nd object 1 0 0 0 TEXT
Statement
A is False Both
and Statement
Statement s A and B
B is True. are False. 1 0 0 0 TEXT

Connectio Connectio
n n
cn=Driver cn=Driver
Manager. Manager.
getConne getConne
ction("jdb ction("jdb
c:odbc c:odbc:ds
","userna n" ,"usern
me", ame",
"passwor "passwor
d"); d"); 0 1 0 0 TEXT

java.sql.Ti java.sql.Ti
me mestamp 0 0 0 1 TEXT

noexecut
execute() e() 0 0 1 0 TEXT

pkg.sql java.sql 0 0 0 1 TEXT

setString( setToStrin
) g() 0 0 1 0 TEXT
DDL
statement
s cannot
be
executed
by making
use of
JDBC, Support
you for DDL
should statement
use the s will be a
native feature of
database a future
tools for release of
this. JDBC 1 0 0 0 TEXT

paused stopped 1 0 0 0 TEXT

1 0 TEXT

TableStat
ement Condition 1 0 0 0 TEXT

0 1 TEXT

Prepared
Statement Condition 0 0 1 0 TEXT

noexecut
execute() e() 0 1 0 0 TEXT

java.sql java.rdb
and and
javax.sql javax.rdb 0 0 1 0 TEXT
select select
ename ,s ename ,s
al ,deptno al ,deptno
from emp from emp
a where a where
a.sal <= a.sal in
(select (select
avg(sal) avg(sal)
from emp from emp
b where b where
a.deptno a.deptno
= =
b.deptno) b.deptno)
order by order by
deptno; deptno; 1 0 0 0 TEXT

2&3 1&4 2&4 1 0 0 0 0 TEXT

Departme
nt Cannot
Marketing predict
Marketing the output
Sales of the
Sales query 0 1 0 0 TEXT

3443500 3443500 344350 0 1 0 0 0 TEXT


adds 10
days to date
the functions
current query cannot be
Timestam contains converted
p error into char 0 1 0 0 0 TEXT

Entity Table
Integrity Integrity 1 0 0 0 TEXT
The
above
query
contains
an error 5 20 1 0 0 0 0 TEXT

Prints -1 Prints 6 Prints 14 0 1 0 0 0 TEXT

All All
supplier supplier
record record
whose whose
name name
starts with starts with None of
% will be ! will be the listed
displayed displayed options 0 0 1 0 0 TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT
TEXT

TEXT
TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT
TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT
TEXT

TEXT

TEXT

TEXT

TEXT

You might also like