JAVAAAmcqfinal
JAVAAAmcqfinal
JAVAAAmcqfinal
(Optional)
class Student {
private String name;
public Student() { }
public Student(String name) {
this.name = name;
this();
}
}
Which of the following statement is true regarding the
above code?
B. private classes
C. abstract classes
Consider the following statements:
I. Cannot be used without inheriting
II. Not possible in Java
III. Can be imported from other packages
Which of the following option gives the exact matches of
above listed items and statements?
class One {
private void method() {
System.out.println("method in One");
}
}
class Two extends One {
void method() {
System.out.println("method in Two");
}
}
Which of the following statements are true regarding the
above code?
1) method() is a overloaded method
2) method() is a overridden method
3) They are independent methods, no connection
between them
4) method() in class Two is polymorphic
5) the access level of method() cannot be expanded from
private to package level
class MethodProvider {
public String message;
void method() {
System.out.println("Built-in method:" + message);
}
}
public class AnonymousOverloading {
public static void main(String args[]) {
MethodProvider mp = new MethodProvider() {
void method(String message) {
this.message = message;
System.out.println("Built-out method:" +
message);
}
};
mp.method("Hello");
mp.method();
}
}
Which of the following option gives the output generated
by the above code ?
class Student {
private Integer id;
private String name;
private Double salary;
public Student() { }
public Student(/* CODE */) {
for(int i=0; i<p.length; i++){
switch(i) {
case 0: id = (Integer) p[i]; break;
case 1: name = (String) p[i]; break;
case 2: salary = (Double) p[i]; break;
}
}
}
@Override
public String toString() {
return "Id:" + id + "\n" +
"Name:" + name + "\n" +
"Salary:" + salary;
}
}
public class VarArgConstructor {
public static void main(String args[]) {
Student s1 = new Student(100, "Mr.X", 28000.0);
System.out.println(s1);
}
}
class Student {
private Integer id;
private String name;
private Double salary;
public Student() { }
public Student(Integer id, String name, Double salary) {
this.id = id;
this.name = name;
this.salary = salary;
}
public Student(Student s) {
/* CODE */
}
}
public class TestCopyConstructor {
public static void main(String args[]) {
Student s1 = new Student(100, "Mr.X", 28000.0);
Student s2 = new Student(s1);
}
}
Which of the following code snippet when replaced for the
comment /* CODE */ in the above program, will correcly
implement the copy constructor?
class Student {
private Integer id;
private String name;
private Double salary;
public Student() { }
public Student(Integer id, String name, Double salary) {
this.id = id;
this.name = name;
this.salary = salary;
}
public void setStudentDetails(Student s) {
System.out.println("Setting Student Details");
this(s.id, s.name, s.salary);
}
public String getStudentDetails() {
String result = "";
result += "Id:" + id + "\n" +
"Name:" + name + "\n" +
"Salary:" + salary;
return result;
}
}
public class TestMethodCall {
public static void main(String args[]) {
Student s1 = new Student(100, "Mr.X", 28000.0);
Student s2 = new Student();
s2.setStudentDetails(s1);
System.out.println(s2.getStudentDetails());
class SuperClass {
protected int param1;
protected int param2;
}
class SubClass extends SuperClass {
private int param3;
private int param4;
SubClass() { }
SubClass(int param1, int param2, int param3, int
param4) {
/* CODE */
this.param3 = param3;
this.param4 = param4;
}
}
public class InitParams {
public static void main(String args[]) {
SubClass sub = new SubClass(1, 2, 3, 4);
}
}
Which of the following code snippets when replaced to
comment /* CODE */ in the above code will correctly
initialize the SuperClass members?
1) param1 = param1;
param2 = param2;
class Person {
private Integer id;
private String name;
}
class Employee extends Person {
private Double salary;
Employee() { }
Employee(Integer id, String name, Double salary) {
this.id = id;
this.name = name;
this.salary = salary;
}
@Override
public String toString() {
return "Id:" + this.id + "\n" +
"Name:" + this.name + "\n" +
"Salary:" + this.salary;
}
}
public class TestEmployee {
public static void main(String args[]) {
Employee e = new Employee(1, "Mr.Employee",
25000.0);
System.out.println(e);
}
}
class SuperClass {
Number giveCalculated(Integer a, Integer b) {
System.out.println("SuperClass");
return a+b * a-b;
}
}
class SubClass extends SuperClass {
/* CODE */
}
Which of the following codes when exclusively replaced to
the comment /* CODE */ in the above code will make the
above program to compile properly?
1) Float giveCalculated(Float a, Float b) {
return a+b * a-b;
}
2) Integer giveCalculated(Integer a, Integer b) {
return a+b * a-b;
}
3) Number giveCalculated(Integer a, Integer b) {
return a+b * a-b;
}
4) Number giveCalculated(Number a, Number b) {
return (Float) a + (Float) b;
}
5) Number giveCalculated(Float a, Float b) {
package me;
import me.you.YourSharedProperty;
/* CODE 1 */ class MyProperty {
void method() {
YourSharedProperty ysp = new YourSharedProperty();
}
}
/* CODE 2 */ class MySharedProperty {
void method() {
MyProperty mp = new MyProperty();
}
}
package me.you;
import me.MySharedProperty;
/* CODE 3 */ class YourProperty {
void method() {
MySharedProperty msp = new MySharedProperty();
}
}
/* CODE 4 */ class YourSharedProperty {
void method() {
YourProperty yp = new YourProperty();
}
class SuperClass {
public /* CODE 1 */ void method1() {
/* CODE 3 */
}
}
class SubClass extends SuperClass {
public /* CODE 2 */ void method2() {
/* CODE 4 */
}
}
Which of the following code snippets when exclusively
replaced to the comments /* CODE 1 */ /* CODE 2 */ /*
CODE 3 */ and /* CODE 4 */ in the above code, will make
the code compile properly?
1) CODE 1 - static
CODE 2 - static
CODE 3 - new SubClass().method2();
CODE 4 - new SuperClass().method1();
2) CODE 1 - No Code
CODE 2 - No Code
CODE 3 - new SubClass().method2();
CODE 4 - new SuperClass().method1();
3) CODE 1 - No Code
CODE 2 - No Code
CODE 3 - SubClass.method2();
CODE 4 - SuperClass.method1();
4) CODE 1 - static
package com.teststatic;
class Static {
static int i=10;
static {
try {
Class.forName("com.teststatic.Static");
i++;
} catch(ClassNotFoundException cnfe) {
System.out.println("Class Not Found");
}
}
}
public class TestStatic {
public static void main(String args[]) {
try {
Class.forName("com.teststatic.Static");
}catch(ClassNotFoundException cnfe) {
System.out.println("Class Not Found");
}
System.out.println(Static.i);
}
}
Which of the following option gives the output for the
above code?
package com.testinstance;
class Instance {
static int i=100;
{
try {
Class.forName("com.testinstance.Instance");
i++;
} catch(ClassNotFoundException cnfe) {
System.out.println("Class Not Found");
}
}
}
public class TestInstance {
public static void main(String args[]) {
try {
Class.forName("com.testinstance.Instance");
}catch(ClassNotFoundException cnfe) {
System.out.println("Class Not Found");
}
System.out.println(Instance.i);
}
}
Which of the following option gives the output for the
above code?
package com.testinstance;
class Instance {
static int i=1000;
{
try {
Class.forName("com.testinstance.Instance");
i++;
} catch(Exception e) {
System.out.println("Exception");
}
}
}
public class TestInstance {
public static void main(String args[]) {
try {
Class.forName("com.testinstance.Instance").newInstance(
);
}catch(Exception e) {
System.out.println("Exception");
}
System.out.println(new Instance().i);
}
}
Which of the following option gives the output for the
above code?
package com.test;
class StaticInstance {
static int i = 10;
static {
i+=10;
try {
Class.forName("com.test.StaticInstance").newInstance();
} catch(Exception e) {
System.out.println("Class Not Found");
}
}
{
i+=10;
}
}
public class TestStaticInstance {
public static void main(String[] args) {
try {
Class.forName("com.test.StaticInstance").newInstance();
} catch(Exception e) {
System.out.println("Class Not Found");
}
System.out.println(StaticInstance.i);
}
}
package com.test;
class TwoStatic {
static int i = 10;
static {
int i = 100;
i += StaticInstance.i;
System.out.println(i);
}
static {
System.out.println(i);
}
}
public class TwoStatic {
public static void main(String[] args) {
System.out.println(TwoStatic.i);
}
}
Which of the following option gives the output for the
above code?
class AllClass {
private static int i = 10;
static { i += 10; }
{ i += 10; }
AllClass() { i += 10; }
AllClass incrementWith10() { i += 10; return this;}
}
public class AllAccess {
public static void main(String[] args) {
System.out.println(new
AllClass().incrementWith10().i);
}
}
Which of the following option gives the output for the
above code?
CoreJava-Annotations-001
CoreJava-Annotations-002
'@Deprecated
'@Override
'@SuppressWarnings
'@Documented
'@Target
CoreJava-Annotations-003
CoreJava-Annotations-004
CoreJava-Annotations-005
CoreJava-Annotations-006
'@Target
'@Retention
'@Override
'@Deprecated
'@Inherited
CoreJava-Annotations-007
CoreJava-Annotations-008
CoreJava-Annotations-009
CoreJava-Annotations-010
CoreJava-Annotations-011
CoreJava-Annotations-012
CoreJava-Annotations-013
CoreJava-Annotations-014
CoreJava-Annotations-015
CoreJava-Annotations-016
CoreJava-Annotations-017
CoreJava-Collections-001
CoreJava-Collections-002
CoreJava-Collections-003
CoreJava-Collections-004
CoreJava-Collections-005
Thread Safety
Type Safety
JVM Safety
Automatic Type Casting
Quicker Garbage Collection
CoreJava-Collections-006
CoreJava-Collections-007
CoreJava-Collections-008
CoreJava-Collections-009
CoreJava-Collections-010
CoreJava-Collections-011
CoreJava-Collections-012
import java.util.Set;
import java.util.TreeSet;
class TestSet {
public static void main(String[] args) {
Set set = new TreeSet<String>();
set.add("Green World");
set.add(1);
set.add("Green Peace");
System.out.println(set);
}
}
CoreJava-Collections-013
CoreJava-Collections-014
CoreJava-Collections-015
CoreJava-Collections-016
CoreJava-Collections-017
CoreJava-Collections-018
CoreJava-Collections-019
CoreJava-Collections-020
CoreJava-Collections-021
CoreJava-Collections-022
CoreJava-Collections-023
CoreJava-Collections-024
CoreJava-Collections-025
CoreJava-Collections-026
CoreJava-Collections-027
CoreJava-Collections-028
CoreJava-Collections-029
CoreJava-Collections-030
CoreJava-Collections-031
CoreJava-Collections-032
The
The
The
The
The
CoreJava-Collections-033
CoreJava-Collections-034
CoreJava-Collections-035
CoreJava-Collections-036
CoreJava-Collections-037
CoreJava-Collections-038
CoreJava-Collections-039
CoreJava-Collections-040
CoreJava-Controlflow-001
cal.add(Calendar.DAY, 5);
cal.roll(Calendar.DAY_OF_MONTH, 5);
cal.set(Calendar.DAY, 5);
cal.roll(Calendar.DAY, 5);
cal.add(Calendar.DAY_OF_MONTH, 5);
CoreJava-Controlflow-002
CoreJava-Controlflow-003
CoreJava-Controlflow-004
CoreJava-Controlflow-005
Integer.parseInt()
Integer.getInteger()
Integer.valueOf()
Integer.intValue()
Integer.decode()
=
==
++
-+
CoreJava-Controlflow-006
CoreJava-Controlflow-007
CoreJava-Controlflow-008
CoreJava-Controlflow-009
CoreJava-Controlflow-010
Which of the following statements are true regarding ifelse structure and switch-case structure?
1) All logics that are implemented with if-else statement is
possible to implement in switch-case structure also
2) Only equality check can be done with switch-case
structure
3) If-else structure can be nested inside a switch-case
structure and vice-versa
4) The case statement in the switch-case structure is an
executable statement
5) Execution control can be manually transfered to any of
the case inside a switch-case structure, using labled break
statement
CoreJava-Controlflow-011
CoreJava-Controlflow-012
CoreJava-Controlflow-013
CoreJava-Controlflow-014
CoreJava-Controlflow-015
CoreJava-Controlflow-016
CoreJava-Controlflow-017
CoreJava-Controlflow-018
CoreJava-Controlflow-019
CoreJava-Controlflow-020
CoreJava-Controlflow-021
CoreJava-Controlflow-022
CoreJava-Controlflow-023
CoreJava-Controlflow-024
CoreJava-Controlflow-025
CoreJava-Controlflow-026
CoreJava-Controlflow-027
CoreJava-Controlflow-028
CoreJava-Controlflow-029
Prints: 1 2 3
Prints: 2 3 4
Forms an indefinite loop at line number 5
Forms an indefinite loop at line number 6
Forms an indefinite loop at line number 7
CoreJava-Exceptions-001
CoreJava-Exceptions-002
CoreJava-Exceptions-003
CoreJava-Exceptions-004
String
StringBuffer
Throwable
Integer
Boolean
CoreJava-Exceptions-005
CoreJava-Exceptions-006
CoreJava-Exceptions-007
CoreJava-Exceptions-008
CoreJava-Exceptions-009
CoreJava-Exceptions-010
CoreJava-Exceptions-011
CoreJava-Exceptions-012
CoreJava-Exceptions-013
CoreJava-Exceptions-014
CoreJava-Exceptions-015
CoreJava-Exceptions-016
CoreJava-Exceptions-017
CoreJava-Exceptions-018
CoreJava-Exceptions-019
CoreJava-Exceptions-020
CoreJava-Exceptions-021
CoreJava-Exceptions-022
CoreJava-Exceptions-023
java.lang.Error
java.io.IOException
java.lang.Throwable
java.lang.Exception
java.sql.SQLException
CoreJava-Exceptions-024
CoreJava-Exceptions-025
CoreJava-Exceptions-026
CoreJava-Exceptions-027
CoreJava-Exceptions-028
CoreJava-Exceptions-029
CoreJava-Exceptions-030
CoreJava-Exceptions-031
CoreJava-Exceptions-032
CoreJava-Exceptions-033
CoreJavaGarbageCollection-001
CoreJavaGarbageCollection-002
CoreJavaGarbageCollection-003
CoreJavaGarbageCollection-004
CoreJavaGarbageCollection-005
CoreJavaGarbageCollection-006
CoreJavaGarbageCollection-007
CoreJavaGarbageCollection-008
CoreJavaGarbageCollection-009
CoreJavaGarbageCollection-010
CoreJavaGarbageCollection-011
CoreJavaGarbageCollection-012
CoreJavaGarbageCollection-013
CoreJavaGarbageCollection-014
CoreJavaGarbageCollection-015
CoreJavaGarbageCollection-016
CoreJavaGarbageCollection-017
CoreJavaGarbageCollection-018
CoreJavaGarbageCollection-019
CoreJava-Inheritance-001
CoreJava-Inheritance-002
CoreJava-Inheritance-003
No
No
No
No
No
No
No
No
No
No
CoreJava-Inheritance-004
CoreJava-Inheritance-005
CoreJava-Inheritance-006
CoreJava-Inheritance-007
CoreJava-Inheritance-008
CoreJava-Inheritance-009
1:class A {
2: void display() { }
3:}
4:class B extends A {
5: // insert missing code here
6:}
CoreJava-Inheritance-010
CoreJava-Inheritance-011
CoreJava-Inheritance-012
CoreJava-Inheritance-013
CoreJava-Inheritance-014
CoreJava-Inheritance-015
CoreJava-Inheritance-016
CoreJava-Inheritance-017
CoreJava-Inheritance-018
CoreJava-Inheritance-019
no
no
no
no
no
no
no
no
no
no
1:class Outer {
2:public static class Inner {
3:}
4:public static void display() { } }
5:public class Test
6:{
7:public static void main(String args[])
8:{
9:// Replace with code from the option below
10:}}
CoreJava-Inheritance-020
}
public class TestB extends TestA
{
protected int a;
private int b;
}
public class TestC extends TestB
{
private int q;
}
Which of the following option gives the lists of instance
data that are accessible in class TestB?
CoreJava-Inheritance-021
CoreJava-Inheritance-022
CoreJava-Inheritance-023
CoreJava-Inheritance-024
CoreJava-Inheritance-025
No
No
No
No
No
No
1:class Test {
2:public static void main (String[] args) {
3:byte b = 1;
4:long lg = 1000;
5:b += lg;
6:
}}
CoreJava-Inheritance-026
CoreJava-Inheritance-027
CoreJava-Inheritance-028
CoreJava-Inheritance-029
CoreJava-Inheritance-030
CoreJava-Inheritance-031
CoreJava-Inheritance-032
CoreJava-Inheritance-033
CoreJava-Inheritance-034
CoreJava-Inheritance-035
CoreJava-Inheritance-036
CoreJava-Inheritance-037
CoreJava-Introduction-001
CoreJava-Introduction-002
CoreJava-Introduction-003
String[] args
String args[]
String ..args
String args
String[] args[]
getClass()
run()
hashCode()
wait()
currentTimeMillis()
equals()
hashCode()
wait()
notify()
clone()
CoreJava-Introduction-004
dollorpack.$pack.$$pack
$$.$$.$$
_score.pack.__pack
p@ckage.subp@ckage.innerp@ckage
.package.subpackage.innerpackage
CoreJava-Introduction-005
CoreJava-Introduction-006
CoreJava-Introduction-007
import
import
import
import
import
com.testpack.TestPack;
com.testpack;
com.testpack.TestPack.*;
static com.testpack.TestPack;
static com.qb2020.TestPack.*;
CoreJava-Introduction-008
CoreJava-Introduction-009
CoreJava-Introduction-010
CoreJava-Introduction-011
Format
Correct Indentation
Generate Getters and Setters
Rename
Move
CoreJava-Introduction-012
CoreJava-Introduction-013
CoreJava-Introduction-014
Object Oriented
Interpreted
Robust
Portable
Secure
CoreJava-Introduction-015
CoreJava-Introduction-016
CoreJava-Introduction-017
CoreJava-IO-001
CoreJava-IO-002
CoreJava-IO-003
File class
FilenameFilter interface
FileFilter interface
FileReader class
FileInputStream class
CoreJava-IO-004
File class
FilenameFilter interface
FileSearchFilter interface
FileInputStream class
FileReader class
CoreJava-IO-005
CoreJava-IO-006
File class
FileInputStream class
FileReader class
InputStreamReader class
BufferedReader
CoreJava-IO-007
CoreJava-IO-008
CoreJava-IO-009
CoreJava-IO-010
CoreJava-IO-011
java.io.BufferedInputStream;
java.io.BufferedReader;
java.io.FileInputStream;
java.io.FileReader;
java.io.IOException;
java.io.InputStreamReader;
CoreJava-IO-012
java.io.Externalizable;
java.io.FileInputStream;
java.io.FileOutputStream;
java.io.IOException;
java.io.ObjectInput;
java.io.ObjectInputStream;
java.io.ObjectOutput;
java.io.ObjectOutputStream;
java.io.Serializable;
CoreJava-IO-013
CoreJava-IO-014
CoreJava-IO-015
CoreJava-IO-016
CoreJava-IO-017
java.io.Serializable;
java.io.FileInputStream;
java.io.FileOutputStream;
java.io.IOException;
java.io.ObjectInput;
java.io.ObjectInputStream;
java.io.ObjectOutputStream;
CoreJava-IO-018
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
public class ListReadOnlyFiles {
public static void main(String[] args) {
File file = new File("D:/Documents");
File[] fileList = file.listFiles(new ReadOnlyFilter());
for (File f : fileList) {
System.out.println(f.getName());
}
}
}
The above written code is intended to list only the readonly files from the folder 'D:/Documents'. The code is
incomplete and any one of the listed class
implementation need to be instantiated and passed as
parameter to the listFiles() method at line number 09 in
the above code.
Which of the following option gives the correct version of
class implementation to make the above code achieve the
required functionality?
CoreJava-IO-019
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
public class ListFiles {
public static void main(String[] args) {
File file = new File("D:/Personal");
Filter filter = new CustomFilter();
File[] fileList = file.listFiles(filter);
for (File f : fileList) {
System.out.println(f.getName());
}
}
}
CoreJava-IO-020
CoreJava-JDBC-001
Type
Type
Type
Type
1
2
3
4
driver
driver
driver
driver
CoreJava-JDBC-002
CoreJava-JDBC-003
CoreJava-JDBC-004
CoreJava-JDBC-005
DatabaseMetaData
Scrollable ResultSets
ResultSetMetaData
Batch Updates
Programmatic inserts, deletes and updates
CoreJava-JDBC-006
CoreJava-JDBC-007
CoreJava-JDBC-008
CoreJava-JDBC-009
CoreJava-JDBC-010
executeQuery()
executeUpdate()
execute()
executeDDL()
executeResult()
CoreJava-JDBC-011
CoreJava-JDBC-012
CoreJava-JDBC-013
CoreJava-JDBC-014
CoreJava-JDBC-015
java.sql.Time
java.sql.ShortDate
java.sql.DateTime
java.sql.Timestamp
java.sql.LongDate
CoreJava-JDBC-016
CoreJava-JDBC-017
CoreJava-JDBC-018
CoreJava-JDBC-019
CoreJava-JDBC-020
CoreJava-JDBC-021
CoreJava-JDBC-022
CoreJava-JDBC-023
CoreJava-JDBC-024
CoreJava-JDBC-025
CoreJava-JDBC-026
CoreJava-Keywords-001
CoreJava-Keywords-002
CoreJava-Keywords-004
CoreJava-Keywords-005
CoreJava-Keywords-006
CoreJava-Keywords-007
CoreJava-Keywords-008
CoreJava-Keywords-009
CoreJava-Keywords-010
CoreJava-Keywords-011
CoreJava-Keywords-012
No
No
No
No
No
No
No
No
No
CoreJava-Keywords-013
no
no
no
no
no
no
no
no
no
CoreJava-Keywords-014
CoreJava-Keywords-015
CoreJava-Keywords-016
CoreJava-Keywords-017
CoreJava-Keywords-018
CoreJava-Keywords-019
CoreJava-Keywords-020
CoreJava-Keywords-021
CoreJava-Keywords-022
CoreJava-Keywords-023
CoreJava-Keywords-024
CoreJava-Keywords-025
CoreJava-Keywords-026
CoreJava-Keywords-027
CoreJava-Keywords-028
CoreJava-Keywords-029
CoreJava-Keywords-030
CoreJava-Keywords-031
CoreJava-Keywords-032
CoreJava-Keywords-033
CoreJava-Keywords-034
CoreJava-Keywords-035
CoreJava-Keywords-036
CoreJava-Keywords-037
CoreJava-Keywords-038
CoreJava-Keywords-039
CoreJava-Strings-001
CoreJava-Strings-002
append(boolean b)
append(byte b)
append(short s)
append(int i)
append(long l)
CoreJava-Strings-003
CoreJava-Strings-004
CoreJava-Strings-005
CoreJava-Strings-006
, (comma)
\t (tab)
\n (new line)
; (semi colon)
\f (form feed)
CoreJava-Strings-007
CoreJava-Strings-008
CoreJava-Strings-009
toString()
concat()
startsWith()
trim()
endsWith()
length()
capacity()
trim()
delete()
replace()
CoreJava-Strings-010
CoreJava-Strings-011
CoreJava-Strings-012
CoreJava-Strings-013
CoreJava-Strings-014
StringBuffer
StringBuffer
StringBuffer
StringBuffer
StringBuffer
is a mutable class
can be extended, since it is mutable
is a sub class of String class
is a Wrapper to the existing String class
class can instantiate String type objects
CoreJava-Strings-015
CoreJava-Strings-017
CoreJava-Strings-018
CoreJava-Strings-019
CoreJava-Strings-020
CoreJava-Strings-021
CoreJava-Strings-022
CoreJava-Strings-023
CoreJava-Strings-024
CoreJava-Strings-025
CoreJava-Strings-026
CoreJava-Strings-027
CoreJava-Strings-028
CoreJava-Strings-029
CoreJava-Threads-001
Whichofthefollowingoptiongivesthestatementsthataretruefor
above?
CoreJava-Threads-002
Fillintheblankwiththevalidanswerfromthebelowgiven
options
CoreJava-Threads-003
CoreJava-Threads-004
CoreJava-Threads-005
CoreJava-Threads-006
CoreJava-Threads-007
CoreJava-Threads-008
CoreJava-Threads-009
CoreJava-Threads-010
CoreJava-Threads-011
CoreJava-Threads-012
CoreJava-Threads-013
CoreJava-Threads-014
CoreJava-Threads-015
CoreJava-Threads-016
CoreJava-Threads-017
CoreJava-Threads-018
CoreJava-Threads-019
CoreJava-Threads-020
CoreJava-Threads-021
CoreJava-Threads-022
CoreJava-Threads-023
CoreJava-Threads-024
CoreJava-Threads-025
CoreJava-Threads-026
CoreJava-Threads-027
CoreJava-Threads-028
CoreJava-Threads-029
CoreJava-Threads-030
CoreJava-Threads-031
CoreJava-Threads-032
Prints: [T1,A][T2,B]
Prints: [T1,B][T2,B]
Prints: [T2,B][T1,A]
Prints: [T2,A][T1,A]
Prints:[T1,A]
CoreJava-Threads-033
CoreJava-Threads-034
CoreJava-Threads-035
CoreJava-Threads-036
CoreJava-Threads-037
CoreJava-Threads-038
CoreJava-Threads-039
CoreJava-Updations in SDK- Which of the following class which is newly added in JDK
001
1.6, provides method to read password?
CoreJava-Updations in SDK- Which of the following method is newly added to the
002
PrintStream class in JDK 1.6?
CoreJava-Updations in SDK- Which of the following option gives the code name for
003
Java SE 6?
CoreJava-Updations in SDK- Which of the following option gives the name of the API
004
which is newly added to Java SE 6?
CoreJava-Updations in SDK- Which of the following option gives the newly added
005
feature to Java SE 6?
CoreJava-Updations in SDK- Which of the following option gives the name of the new
006
type of parser added to the XML API, in JDK 1.6?
CoreJava-Updations in SDK- Which of the following option gives the name of the
007
Collection implementation class that implements the
Correct answer
A-II, B-III, C-I
Wrong answer
A-III, B-I, C-II
Wrong answer
A-I, B-II, C-III
Default
Constructors are
Optional for all
classes
Can be
Abstract classes
overloaded across cannot have
inherited classes constructors
Parameterized constructors
can accept variable
arguments as their
parameters
Parameterized
constructors
cannot accept its
same class type
as parameter
Parameterized
constructors
cannot accept
final arguments as
parameters
Wrong answer
A-II, B-I, C-III
Parameterized
constructors
cannot call the
default constructor
Using Var-Args
Using non-static
overloaded
methods
1,2
2,3
3,4
4,5
1,2
2,3
3,4
4,5
Overloaded
methods should
always return
same type of
value
Overloaded
methods cannot be
declared as
abstract
2,5
1,2
2,3
3,4
Overloaded
methods cannot
start with a
special character
like '_'
Overloaded
methods should be
declared as public
1,2,5
2,3,4
3,4,5
1,2,4
Private level
access is
applicable for
both classes and
its members
Public is
applicable for
local variables
Package level
access is only for
members, not for
classes
3,4
1,2
2,3
4,5
Normal Version
HiHelloWelcomeBye
Var-arg Version
HiHelloWelcomeByeGood
Night
Normal Version
HiHelloWelcomeB
ye
Normal Version
HiHelloWelcomeB
yeGood Night
Var-arg Version
Compile time error
HiHelloWelcomeBy 'Ambiguity in
e
resolving the
Var-arg Version
method
HiHelloWelcomeBy stringProcessor()'
eGood Night
Array Version
100
Array Version
150
Normal Version
100
Array Version
150
Normal Version
100
Normal Version
100
Array Version
10.0
Array Version
15.0
Normal Version
10.0
Array Version
15.0
Shows a compile
time error for both
the methods
'Duplicate methods
numericProcessor(.
..)'
Built-out method:
Hello
Built-in method:
Hello
Runtime Error
'Unable to resolve
the method
method(String)'
Built-out method:
Hello
Built-in method:
null
CODE 1 - Object
CODE 2 - Object
CODE 1 - Integer
CODE 2 - Integer
CODE 1 - Float
CODE 2 - Float
CODE 1 - String
CODE 2 - String
Object o
Object o[]
Student(s.id,
new Student(s.id, Student(s);
s.name, s.salary); s.name, s.salary);
Cannot call
overloaded
constructors using
this() method
4,5
1,2
2,3
3,4
Prints
Runtime error
Id:1
Name:Mr.Employe
e
Salary:25000.0
Compiles and
executes
successfully, but
No Output
1,4,5
1,2,3
2,3,4
3,4,5
1,2
2,3
3,4
4,5
1,2,4
2,3,4
1,2,5
3,4,5
10
102
40
20
110
10
10
110
110
10
3,5
1,2
2,3
3,4
Prints: 40
Prints: 50
@interface
@annotation
@annotate
@meta
1,2,3
2,3,4
3,4,5
1,2,5
Try-Catch Blocks
Methods
ElementType.TYPE
3,4,5
1,2,3
2,3,4
1,4,5
An annotation is a special
kind of modifier
An annotation can
be declared at
public, private,
protected and
package access
levels
Annotation
Annotations can
methods allow
replace interfaces
wrapper types as in Java
its return types, as
an alternative to
its equivalent
primitive types
Annotations
Interfaces
Enums
Classes
2,3,5
1,2,3
2,3,4
3,4,5
@Retention
@Target
@Accessible
@Runtime
@Target
@Element
@ElementType
@Use
2,3
1,2
3,4
4,5
1,4
2,3
3,4
4,5
1,4
2,3
@Retention(RetentionPolicy.
RUNTIME)
@Target(ElementType.METH
OD)
public @interface PreInit {
int initValue() default 0;
}
3,4
4,5
The @Override
can be used only
while overriding
an abstract
method in the
super class
@Retention(Reten @Retention(Reten
tionPolicy.REFLEXI tionPolicy.RUNTIM
VE)
E)
@Target(ElementT @Target(ElementT
ype.METHOD)
ype.METHOD)
public @interface public @interface
PreInit {
PreInit {
int initValue()
int initValue() =
default 0;
0;
}
}
@Retention(Retenti
onPolicy.REFLEXIVE
)
@Target(ElementTy
pe.METHOD)
public @interface
PreInit {
int initValue() =
0;
}
2,3
1,2
3,4
4,5
Statement A is
True and
Statement B is
false
Both the
Statements A and
B are true
1-A, 2-B, 3-C, 4-D 1-A, 3-B, 4-C, 2-D 2-A, 4-B, 3-C, 1-D
LinkedList
ArrayList
Collection
List
2,4
1,2
2,3
4,5
Use of generic
collections
removes thread
safety for the
collection class
being used
Statement A is
true and
Statement B is
false
Statement A is
false and
Statement B is
true
Creates a Date
Creates a Date
object with '01object with 0 as
01-1970 12:00:00 default value
AM' as default
value
Both the
Statements A and
B are true
Creates a Date
object with current
date alone as
default value
B,D
A,B
B,C
for (Iterator<String>
for
for
myListIterator =
(<String>Iterator (Iterator<String>
myList.iterator();
myListIterator = myListIterator =
myListIterator.hasNext(); ) { myList.iterator(); myList.iterator();
String myElement =
myListIterator.has myListIterator.Nex
myListIterator.next();
Next(); ) {
t(); ) {
String
String
System.out.println(myEleme myElement =
myElement =
nt);
myListIterator.nex myListIterator.nex
}
t();
t();
D,E
for
(<String>Iterator
myListIterator =
myList.iterator();
myListIterator.hasS
tring(); ) {
String
myElement =
myListIterator.next(
);
3, 4, 5, 7
3, 5, 7, 4
3, 5, 7, 7, 4
7, 5, 4, 3
{ee=ff, gg=hh}
{ee=ff}
Both Statements
A and B are true
Statement A is
false and
Statement B is
true
Both Statements A
and B are false
[GSLV, SLV,
Chandrayaan]
String dateFormat =
"dd/MM/yyy hh:mm:ss a";
String timeFormat =
"hh:mm:ss a";
LinkedHashSet
HashSet
Hashtable
TreeSet
HashMap
HashSet
ArrayList
LinkedList
Queue
HashSet
Stack
HashMap
Iterator
Enumerator
Enumeration
Remover
ListIterator
Enumerator
Iterator
java.util.Date
java.util.Calendar
java.util.Time
java.util.Date
Enumeration
java.util.Timestamp
public List<Map<String,
Object>> getRows();
public
public
List<VariableObje List<Object>
ct> getRows();
getRows();
private Map<User,
Set<Account>> users =
null;
private
Map<Account,
Set<User>>
users = null;
public List<String>
getRows();
public
SortedSet<Map<String,
Object>> getRecords();
public
public
public List<String>
List<VariableObje Set<Map<String, getRecords();
ct> getRecords(); Object>>
getRecords();
1,3
2,3
3,4
4,5
List<Byte>
List<Short>
elements = new elements = new
ArrayList<Byte>() ArrayList<Short>();
;
1,2
2,3
3,4
4,5
Prints: 1 -1
Prints: 1 0
Prints: 2 0
Prints: 2 -1
[3]
[1, 3, 2, 1]
[1, 3, 1, 3, 1]
[1, 3, 2]
2,3
1,2
3,4
4,5
Compile time
error at line
number 09
Prints the
following without
any error
Windows
Linux
Mac OS
Windows
Linux
Mac OS
Runtime Exception
Prints:
Chennai Delhi
Pune Kolkata
Prints:
Chennai Pune
Mumbai Kolkata
Compile Time
Exception
LINE 1:
cal.add(Calendar.DAY_OF_M
ONTH, -120);
LINE 2:
cal.add(Calendar.DAY_OF_M
ONTH, 240);
LINE 1:
cal.add(Calendar.
DAY_OF_MONTH,
-120);
LINE 2:
cal.add(Calendar.
DAY_OF_MONTH,
120);
LINE 1:
cal.subtract(Calen
dar.DAY_OF_MONT
H, 120);
LINE 2:
cal.add(Calendar.
DAY_OF_MONTH,
240);
LINE 1:
cal.subtract(Calend
ar.DAY_OF_MONTH,
120);
LINE 2:
cal.add(Calendar.D
AY_OF_MONTH,
120);
2,5
1,2
2,3
3,4
1,2,5
2,3,4
3,4,5
1,4,5
toOctalString()
byteValue()
intValue()
isInfinite()
1,4
2,3
3,4
3,5
3,4,5
1,2,3
2,3,4
1,4,5
while loop
for loop
2 4 8 16 32 64
2 4 8 16 32
24816
return
break
continue
goto
1,3,4
2,4,5
1,2,3
2,3,4
2,3
1,2
3,4
4,5
new Character("a");
new Byte("10");
old truth
new truth two
old truth
new truth one
Compilation Error
Result: 100
Result: 100
Runtime Error
End of getSquare
1,2,3
2,3,4
3,4,5
1,4,5
Auto-boxing: 3, AutoUnboxing: 2
Auto-boxing: 4,
Auto-boxing: 1,
Auto-boxing: 2,
Auto-Unboxing: 3 Auto-Unboxing: 0 Auto-Unboxing: 0
for-each loop can work only for-each loop is an for-each loop does for-each loop is an
with generic collections
alternative to
the automatic
alternative to
Enumeration
typecasting
Iterator
The variable used for
iterating should of
java.lang.Object type
The collection
The variable used The collection
should be
for iterating
object should be
java.util.List type should of
delcared as final
java.lang.String
type
2,5
1,2
2,3
1411
java.lang.Integer
1411
1411
java.lang.Number java.lang.Object
3,4
3,4
1,2
2,3
4,5
2,3
1,2
3,4
4,5
Prints:
Save Our Tigers
Share this
Shows compile
time error that
labeled break
cannot be used
with switch
statement
false
false
true
false
true
true
false
true
Wrapper Base
Runtime Error
Var-args
Long Wrapper
GB
RGB
No output
These kind of
problems cannot
be solved using ifstatement
3 000012
Inserting a break
statement at the
else part of every
if-statement
except the
outermost ifstatement will
make the program
to correctly
calculate the
grade
No changes
required. The
program correctly
calculates the
grade
0012
0000001112
1,4
2,3
1,4
3,5
Prints: aeTgr
Prints: eTgr
After printing
After printing eTgr
aeTgr throws
throws
StringIndexOutOfB StringIndexOutOfB
oundsException
oundsException
the overriding
method cannot redeclare the
Unchecked
exceptions, that
are declared by
super class
method.
java.lang.Exceptio java.lang.Error
n
java.lang.Throwabl
e
1,3
2,3
4,5
3,4
1,3
1,2
2,3
3,4
2,3,5
1,2,3
2,3,4
3,4,5
3,4
1,2
2,3
4,5
1,3,5
1,2,3
2,3,4
3,4,5
2,3
1,2
3,4
4,5
Prints "Previous
Exception"
Prints "Last
Exception"
Prints
Exception
Compiler time
error
Userdefined
exceptions should
extend Exception
Prints
Error caught
Compile time
Compile time error Run time error
error
Cannot catch Error test() method does
Error class cannot type objects
not throw an Error
be extended
type instance
Finally Inner
Exception outer
Finally Outer
Finally Outer
Exception Outer
Exception Outer
Finally Inner
Finally Outer
Exception Outer
Finally Outer
Prints "Problem
found"
Runs with No
output
Compile Time
Error
Executes without
any output
Compile time
error; the
declaration does
not match the
throw statement
Compiles
successfully. But
throws runtime
error while
executing
2,3
1,2
3,4
4,5
public void
behaviour()
System.out.println("Behavio throws
ur Implemented");
SQLException {
}
System.out.printl
n("Behaviour
Implemented");
}
public void
behaviour()
throws
IOException,
SQLException {
public void
behaviour() throws
Exception {
System.out.println(
"Behaviour
System.out.println Implemented");
("Behaviour
}
Implemented");
}
1,2,3
2,3,4
3,4,5
1,4,5
Prints:
Test
then throws
NullPointerException on the
console
Prints:
Prints:
Prints:
Test
Exception caught Exception caught
NullPointerExcepti Test
NullPointerExceptio
on caught
n caught
1,3,4
1,2,3
2,3,4
3,4,5
Prints:
Problem in PlanetX
Prints:
Problem in
Universe
Problem in
Universe
Prints:
Prints:
Problem in
Problem in
PlanetX
Universe
Problem in PlanetY
Compilation Error
Prints:
Prints:
Prints:
Specifc Problem 1 Specifc Problem 2 Specifc Problem 1
Specifc Problem 2
1,5
1,2
2,3
3,4
Shows,
Unreachable
catch block for
Exception, at line
number 6
Shows, cannot
Shows,
create anonymous RuntimeException
user defined
at line number 5
exception class, at
line number 12
NullPointerException
finally
finally
IndexOutOfBounds NullPointerExceptio
NullPointerExcepti Exception
n
on
finally
finally
finally
IllegalArgumentEx IllegalArgumentExc
IllegalArgumentEx ception
eption
ception
finally
finally
finally
NullPointerExcepti IndexOutOfBounds
IndexOutOfBound on
Exception
sException
finally
finally
RuntimeException
NullPointerException
IndexOutOfBoundsExceptio
n
IllegalArgumentException
RuntimeException
RuntimeException
RuntimeException
RuntimeException
1,2
2,3
3,4
4,5
finally method1
IOException
finally method1
finally method1
FileNotFoundExce
ption
FileNotFoundExcept
ion
finally method1
Returning from
inner try
100
Shows compile
time error
'Unreachable code
at line numbers 11
and 15'
Strong Reference
Weak Reference
Phantom Reference
Soft Reference
testObject = null;
1,5
1,2
2,3
3,4
2,4
1,2
2,3
3,5
Soft Reference
Weak Reference
Phantom
Reference
Strong Reference
1,5
2,3
3,4
1,4
1 object
3 objects
2 objects
0 object
1 object
2 objects
3 objects
0 object
firstString = null;
secondString =
null;
firstString = null;
string = null;
stringBuilder =
null;
stringBuffer = null;
stringBuilder =
null;
stringBuffer =
null;
2,3
1,2
3,4
1,4
System.free();
System.gc();
Line No. 13
Line No. 09
Line No. 12
Line No. 11
3 objects
1 object
2 objects
0 object
At the line
commented as //
LINE 3
At the line
commented as //
LINE 1
1,5
3,4
4,5
2,3
Declaration 1,3,4
Declaration 2,4
Declaration 1,2,3
Declaration 2,3,4
Has-a
relationships
always rely on
inheritance.
Has-a
relationships
always require at
least two class
types.
Has-a relationships
always rely on
polymorphism.
10,20
20,10
Compilation error
at line no:9
Runtime error at
line no 12
Addition Method
returns nothing
Compilation fails
hello
nullJAVA
hello JAVA
1,4
2,3
3,4
4,5
public void
public float
public double
getNum(double d) getNum() { return getNum(float d)
{}
4.0f; }
{ return 4.0d; }
Statement A is
Statement A is
Both Statements A
false and B is true true and B is false and B are false
2,4
1,2
2,3
3,4
100,10
100100
10,10
Compilation error
public class
Manager
implements
Payroll extends
Employee {
public void
getSalary() { /*do
something*/ }
}
public class
Manager extends
Payroll
implements
Employee
public void
getSalary (){ /*do
something*/ }
public void
Payroll.getSalary()
{ /*do
something*/ }
}
public class
Manager
implements Info
extends Employee
{
public void
Employee.getSalar
y(){ /*do
something*/ }
public void
getSalary (){ /*do
something*/ }
}
class Shyam
implements Tree
{}
class Shyam
class Shyam
{ private
extends Tree { }
BestFriend Tree; }
Zippo
An exception
Compilation fails
occurs at runtime because of an
at line 10.
error in line 3.
Compilation fails
because of an error
in line 9.
Both the
statements are
false
Compilation fails
An exception
occurs at runtime.
Runnable r = new
Runnable() { };
Fred
Outer.Inner o = new
Outer.Inner();
Outer.Inner oi =
new Inner();
Outer o = new
Inner oi = new
Outer();
Outer.Inner();
Outer.Inner oi =
o.new
Outer.Inner();
x, z, a, b
x, y, z, a
x, y, z, a, b
z, a, b
Runtime Error at
line no 7
10
interface A,B
interface B,C,D
interface A,B,C
interface B,C,D
Compilation Error
11
Runtime error
Runtime error at
line no 5
x, y, z, a, b
Compile time
error at line no 5
Runtime error at
line no 5
Top, i1=1,i2=2
200100100
200100200
Compilation Error
Line no 4
Line no 2
Line no 3
Line no 1
main,First
Runtime error at
line no 2
main,Second
JasmineSunflower
RoseSunflower
JasmineLilly
RoseLilly
Runtime error
caused by input
not declaring
Exception
1,2,3
2,3,4
3,4,5
1,3,5
2,5
1,2
2,3
3,4
3,4
1,2
2,3
3,5
1,2,3
2,3,4
3,4,5
1,3,5
1,2,3
3,4,5
1,4,5
Java Debugger
2,3,4
2,3
1,2
3,4
4,5
1,2,3
2,3,4
3,4,5
1,4,5
Project
References
Run/Debug
Settings
Resource
1,2,3
2,3,4
3,4,5
2,4,5
Helps Javadoc to
build the Java
Documentation
easily
Compiler throws a
compilation error
'Too many main()
methods'
4,5
3,4
1,2
2,3
Classes can be
Classes cannot be
loaded at
loaded at Runtime
Runtime, but the
name of the class
with full package
name should be
given in the code
at compile time.
Packages in the
extension
directory of JRE /
JDK
User-defined
packages and
libraries
Java Class Library
Packages in the
extension
directory of JRE /
JDK
Java Class Library
User-defined
packages and
libraries
User-defined
packages and
libraries
Java Class Library
packages in the
extension directory
of JRE / JDK
3,4
1,2
2,3
4,5
2,3
1,2
3,4
4,5
1,2,3
2,3,4
3,4,5
1,4,5
File class
FileProperties
class
Properties class
System.properites
1,2
2,3
3,4
4,5
2,4,5
1,2,3
2,3,4
1,4,5
2,3
1,2
3,4
4,5
RandomAccessFile
FileReader
DataInputStream
and
FileInputStream
FileInputStream
CardInfo
Product
Cart
UserInfo
Task III
Task II
Task I
Task IV
RandomAccessFile
BufferedReader
and
BufferedWriter
FileReader and
FileWriter
BufferedInputStrea
m and
BufferedOutputStre
am
1,2,4
1,2,3
3,4,5
1,4,5
2,5
1,2
2,3
3,4
import java.io.Serializable;
import
import
import
java.io.Serializabl java.io.Serializable java.io.Serializable;
class CardInfo {
e;
;
public String cardNo;
interface CardInfo
public String cvvNo;
class CardInfo { class
{
}
public String
CustomerInfo
public String
cardNo;
implements
cardNo();
class CustomerInfo extends
public String
Serializable {
public String
CardInfo implements
cvvNo;
public String
cvvNo();
Serializable {
}
customerId;
}
public String customerId;
public String
public String
class
customerName;
class CustomerInfo
customerName;
CustomerInfo
public volatile
implements
}
implements
String cardNo;
CardInfo,
Serializable {
public volatile
Serializable {
public String
String cvvNo;
public String
customerId;
}
customerId;
public String
public String
customerName;
customerName;
public CardInfo
public String
cardInfo;
cardNo() { return
}
null; }
public String
cvvNo() { return
null; }
}
Runtime Error
'IllegalArgumentException:
invalid file open mode'
No errors;
Runtime Error 'IOException:
Compile time
use shared
error 'Unhandled
more to open
Exc
program compiles
and executes
properly.
Appends the text
"Next Info" at the
end of the file
'C:/TestRandom.tx
t'
Compile time
error 'Unable to
resolve the
method
read(byte[], int,
int)
Runtime error
'Invalid file open
mode'
Compiles and
executes properly.
Reads and prints
the last 7 bytes
from the file
'C:/TestRandom.txt'
2,3
1,2
3,4
4,5
Throws runtime
error while
reading the object
'Not a Serialized
Object'
Throws compile
time error
'Unsupported
Serializable
object'
No errors in the
program. But fails
to Serialize the
object. So blank
space is printed
class ReadOnlyFilter
implements FileFilter {
public boolean accept(File
file) {
if(file.canRead() && !
file.canWrite())
return true;
else
return false;
}
}
class
ReadOnlyFilter
implements
FileFilter {
public boolean
accept(File file) {
class
ReadOnlyFilter
implements
FileFilter {
public boolean
accept(File file) {
class
ReadOnlyFilter
implements
FileFilter {
public boolean
accept(File file) {
if(file.isReadOnly() if(file.canRead()
if(file.canRead())
)
&& file.canWrite())
return true;
return true;
return true;
else
else
else
return false;
return false;
return false;
}
}
}
}
}
}
1,3
1,2
2,3
3,4
Type 3
Type 2
Type 1
Type 4
Type 4 driver
Type 2 driver
Type 3 driver
Type 1 driver
-1
0 null
2,4,5
1,2,3
2,3,4
1,4,5
getMetaData()
getResultSetMeta getMetaInfo()
Data()
getMetaData()
Driver
DriverManager
Connection
ResultSet
java.sql.Timestamp
java.sql.Date
java.sql.Time
java.util.Date
2,3
1,2
3,4
4,5
DatabaseMetaData
ResultSetMetaDat ResultSet
a
All IN
All INOUT
No registration is
parameteres must parameteres must required for any
be registered with be registered with type of parameter
CallableStatemen CallableStatement
t object prior to
object prior to the
the execution
execution
CONCUR_READ_ONLY
getResultSetMetaIn
fo()
RowSet
The setter
The register methods
Theare
values
usedshould
to set the
be passed
values for
as pa
th
methods are used
to set the values
for the new row
1,4
2,3
DatabaseMetaData
ResultSetMetaDat Connection
a
Driver
Starts a new
Transaction and
executes all the
SQL statements,
under that single
transaction
There is no relation
between
transactions and
auto-commit
feature
1,3
3.5
3,5
1,2
2,3
3,4
DDL statements
can be executed
only using
Statement
interface
getTables() method in
DatabaseMetaData can be
used to query the available
table names
isTableAvailable()
method in
DatabaseMetaDat
a can be used
Querying a table
using Statement or
PreparedStatement
throws
SQLException, if
the table is not
available. Thus it
can be decided
that the table does
not exist
2,3,4
1,2,3
3,4,5
1,4,5
Throws an
SQLException
stating the error
Returns an Object
array that
contains the
values of all
matching columns
There cannot be
more than one
column with the
same name in a
Query as well as in
the ResultSet
The ResultSet
object remains as
disconnected
ResultSet with the
previous results
The ResultSet
object gets
updated with the
latest changes in
the data
The data in
ResultSet object
becomes Read-only
SQLException is thrown at
the line number 3
SQLException is SQLException is
PreparedStatement
thrown at the line thrown only at the cannot detect the
number 2
time of processing non-existence of
the ResultSet
table
object rs
1,3,4
1,2,3
3,4,5
1,3,5
Face value
System value
Main value
System value
Main value
Face value
Face value
Main value
System value
Main Value
Face Value
System Value
1245
1234
1342
12345
Only B is true
Only A is true
Prints the output "The Value Prints the output Compile time error Compiles
of byte b is:-126
"The Value of byte at line number 4 successfully but
b is:130
throws runtime
error at line no 4
cdefghi
bcdefgh
abcde
bcdef
Statement A is
Statement A and
true and B is false B are true
Both Statements A
and B are false
createOutputFile()
testSomethingWithFile()
deleteOutputFile()
createOutputFile()
deleteOutputFile()
testSomethingWit
hFile()
testSomethingWit
hFile()
createOutputFile()
deleteOutputFile()
deleteOutputFile()
createOutputFile()
testSomethingWith
File()
Runtime Error
truetruefalse
truetruetrue
The Person Name is female The Person Name The Person Name The Person Name
Jimmy
is Cameron Jimmy is Jimmy
is female Cameron
Jimmy
A,B,C,D is true
Program
Program compiles
successfully
and but throws a
executes and
runtime error
prints value of c
is 2
Program
successfully
executes but prints
value of c is
ooxxoe
Statements B,C
Statement B and
and D are correct C are correct
Statement A is
correct
null,1,a
0,1,a
Mr.Jones
Ms.Smith
Ms.Jones
Mr.smith
Mrs.Jones
Ms.Smith
Mr.Jones
Mrs.Smith
Rose
Lotus
Lilly
Pink
Lotus
Lilly
Pink
White
Violet
Compilation Error
at line no 10
KeepSmiling!..
Noon
Evening
Night
GoodMorning
Noon
Evening
Night
GoodMorning
GoodAfterNoon
GoodEvening
GoodNight
Morning
Noon
Evening
Night
Integer.MIN_VALUE
Integer.MAX_VALU
E
3,4
0 None of listed
options
Infinity
-Infinity
3.4E99
Runtime Error
2,2,1
2,2,2
0.2,0.5,0.5
1,2,2
9,6
15,6
15,9
Runtime error
Only A is correct
A and C are
correct
A and D are
correct
Value Returned
from the method
is:10
Value Returned
from the method
is:14
Runtime error at
line number 5
The above mentioned code class Play cannot An Enum can not
will fail to compile.
access the enum define an abstract
constant FootBall method.
without
instantiation.
If the enum
'Games' is defined
as an abstract
'enum', it will
compile
successfully.
It declares values to be a
reference to an array object
and constructs an array
object containing 10
integers which are
initialized to zero.
It declares values
to be a reference
to an array which
contains 10
references to int
variables.
10,18
18,10
5,9
1,2,null
for ( int j =
names.length; j >=
0; j++ )
if ( names[j] !=
null )
System.out.println System.out.println(
System.out.printl ( names[j] );
names[j] );
n( names[j] );
System.out.println
(Grade.Personality.ASSERTIV
E instanceof
Grade.Personality);
System.out.printl
n
(Personality.EXPR
ESSIVE instanceof
Personality);
POOR Performance:Revised
Salary = 100.0
AVERAGE
Performance:Revised Salary
= 105.0
GOOD Performance:Revised
Salary = 120.0
EXCELLENT
Performance:Revised Salary
= 145.0
POOR
Performance:Revi
sed Salary =
100.0
AVERAGE
Performance:Revi
sed Salary =
105.0
GOOD
Performance:Revi
sed Salary =
125.0
EXCELLENT
Performance:Revi
sed Salary =
140.0
The constructor of
an enum cannot
accept 2 method
parameters
Ruppee
Doller
Red
Yellow
Ruppee
Doller
Blue Ruppee
Yellow Doller
Red
Blue
Ruppee
Doller
Dinar
Blue
Red
Yellow
5,20
20,10
10,20
5,10
Garden status is
Garden limit on
the edge
short:0..1
byte:0..1
short:1..99
byte:1..99
short:32,768..32,767
byte:-128..127
short:2,147,483,648 ..2,1
47,483,647
byte:1..99
Code compiles
successfully and
executes
successfully
Code compiles
successfully;
generates runtime
error at line no 8
Code compiles
successfully;
generates runtime
error at line no 9
2,3
1,2
1634
Comparing memory
references of two objects
3,4
1632
Comparing
content of two
objects
4,5
1616
1734
Ensuring the
objects added to
JVM's Object pool
Line 1
Line 2
Line 3
1,4
2,3
3,4
4,5
NumberFormatException
IllegalArgumentEx ParseException
ception
ArithmeticExceptio
n
2,4
1,2
3,4
4,5
2,4
1,2
3,4
3,5
toString()
concat()
replace()
substring()
intern()
join()
trim()
toString()
Code Snippet 2
uses more JVM
memory than
Code Snippet 1
for storage
1,5
2,3
3,4
3,5
44
21
39
16
Prints false
Throws
Throws
Prints null
ParseException at IllegalArgumentEx
line 2
ception at line 2
Prints true
Throws
Throws
Prints false
NullPointerExcepti IllegalArgumentEx
on at line 3
ception at line 2
consistency
symmetry
There is no connection
between equals() method
and hashCode() method in
the Object class. The
equals() simply compares
only the memory references
of current object and object
to be compared using ==
operator.
The equals()
There is no
method compares connection
the hash code of between equals()
current object and method and
object to be
hashCode()
compared, by
method in the
calling
Object class. It
hashCode()
simply compares
method and
only the content
returns true if
of both the object
their hash code
by just calling
matches, and
equals() method
false otherwise.
on the current
object by passing
the object to be
compared.
transitivity
reflexivity
The equals()
method uses an
object comparison
algorithm which
takes two different
hash codes and
evaluates to either
true or false. The
same is returned
by equals()
method.
Overriding of
hashCode()
method is not
required. The
implementation of
hashCode()
method in the
Object class itself
will serve all the
purposes
Overriding of
equals() method is
not required. The
implementation of
equals() method in
the Object class
itself will serve all
the purposes
PeaWithPlay
PlayWithNuts
WithPeaNuts
PlayWithPea
WithPeaNuts
PlayWithNuts
PlayWithPea
PeaWithPlay
The Thought is
The thought is
Green,
Green, so is the
world
so is the World
10
11
public boolean
equals(Object obj) {
if(obj != null && obj
instanceof MyClass) {
MyClass that =
(MyClass) obj;
return (this.a == that.a)
&& (this.b == that.b);
}
return false;
}
public boolean
equals(MyClass
that) {
if(that != null)
{
return (this.a ==
that.a) && (this.b
== that.b);
}
return false;
}
public boolean
None of the listed
equals(Object
implemention is
obj1, Object obj2) valid
{
if(obj1 != null
&& obj2 != null
&& obj1
instanceof
MyClass
&& obj2
instanceof
MyClass) {
MyClass this
= (MyClass) obj1;
MyClass that
= (MyClass) obj2;
return (this.a ==
that.a) && (this.b
== that.b);
}
return false;
}
public int
hashCode() {
return
this.hashCode;
}
Implementation of
hashCode() is not
required. Set is
capable of finding
duplicates by
default
public int
hashCode() {
return (int)
System.currentTi
meMillis();
}
public int
hashCode() {
return
super.hashCode();
}
public int
hashCode() {
return
super.hashCode()
+
name.hashCode();
}
public int
hashCode() {
public int
hashCode() {
return
super.hashCode() super.hashCode();
+ 1000;
}
}
public int
hashCode() {
return
longitude.hashCod
e() +
latitude.hashCode(
)+
super.hashCode();
}
2, 4
2, 3
3, 1
1, 2
DeadLock Condition
Lock Starvation
Condition
Race Condition
Lock Release
Condition
wait()
notify()
notifyAll()
sleep()
Statement A is true
and B is false
2,5
1,2
2,3
3,4
Statement A is true
and B is false
1,4
4,5
2,3
3,4
Prints I am RunningThread
infinitely.
Compiles
successfully but
generates no
output
RunTime error
Prints I am
RunningThread
Three Times
3,5
1,2
2,3
3,4
Compilation Error
at Line no 1
Thread t = new
Thread(this);
t.start();
start();
Thread t = new
Thread(this);
this.start();
Thread t = new
Thread();
this.start(t);
Prints 0
Prints 1
12
123
124
2,5
1,2
2,3
3,4
1,3,4
1,2,3
2,3,4
3,4,5
A compile time
error indicating
that no run method
is defined for the
Thread class
synchronized(charlie)
{ charlie.notifyAll(); }
NatureTitanicGivesEnergy
HoneyBeeHoneyBee
HoneyBee
HoneyHoneyBee
Runtime Error
RunningTree
GreenPlanetGreen StartingTree
PlanetGreenPlane
t
Runtime error at
Line no 1
Prints the
Prints
Prints the following
following output 2 MachineRunning output 1 time:
times:
and thows a
Guns
Guns
Runtime Exception (waits for 1000
(waits for
milli seconds)
1000 milli
Pistols
seconds)
Pistols
prints output: 0q
prints output: 1
Compilation error
at Line no 1
1,3
2,3
3,4
4,5
1,3
2,3
1,2
3,4
Prints: ABC
Prints: AYZ
Prints: ABZ
Prints: XYZ
1,3
2,3
3,4
4,5
2,4
1,2
2,3
3,4
1,3
2,3
1,2
3,4
1,2
2,3
3,4
4,5
new Thread(new
RunnableTask()).start();
new Thread(new
Task()).start();
new Thread(new
Runnable(new
Task())).start();
new Thread(new
Runnable(new
RunnableTask())).st
art();
ABC
XYZ
Console
Terminal
Output
Input
clearError()
checkError()
printf()
format()
Mustang
Kestrel
Merlin
Tiger
Image Morphing
API for Java 3D
JDBC 4.0
Annotations
Var-args
Generics
StAX
JAX
DOM
SAtX
TreeSet
HashSet
NavigableHashSet NavigableTreeSet
java.util.spi
java.util.concurre java.util.logging
nt
java.util.regex
ArrayDeque
Deque
BlockingDeque
LinkedDeque
Wrong answer
Marks
2
1,5
2,5
1,3
2,4,5
1,5
CODE 1 - Number
CODE 2 - Number
Copy constructor is
not possible in Java
1,5
1,3,4
1,5
2,4,5
110
110
110
4,5
@metadata
1,3,4
Classes
ElementType.ENUM
2,3,5
2,4,5
@Reflexive
1,5
2,5
1,5
1,5
Vector
1,5
A,E
ArrayList
Comparator
Browser
public Set<Object>
getRecords();
1,5
List<Integer>
elements = new
ArrayList<Integer>(
);
1,5
3,4
Prints:
Chennai Delhi
Mumbai Kolkata
3,5
Runtime error
1,2,3
2
1,5
1,3,4
3,4,5
1,4
new
Boolean("truth");
End of getSquare
Result: 100
1,3,4
1,5
Runtime error
'Unable to convert a
long value to Object
type'
1,5
1,5
Compile-time Error
2,5
2
1,5
1,4
1,4,5
3,5
1,3,4
1,5
Finally Inner
Finally Outer
Exception Outer
1,5
public void
behaviour() throws
IOException {
System.out.println("
Behaviour
Implemented");
}
1,2,5
1,4,5
Runtime Error
3,5
1,5
testObject.delete();
2,4
4,5
3,5
3,5
1,4
2,5
public class
Manager
implements Payroll
extends Employee {
public void
getSalary (){ /*do
something*/ }
public void
Payroll.getSalary()
{ /*do
something*/ }
}
class Shyam
{ private
Tree<bestFriend> }
Compilation fails
because of an error
in line 10.
System.out.println(n
ew Runnable(public
void run() {}));
a, b
1,3,4
3,5
1,5
2,3,4
1,4,5
1,5
1,2,4
Java Compiler
1,2,5
1,5
2,5
1,5
1,2,5
1,5
1,2,4
1,5
LookupStream
Customer
Task V
FileInputStream and
FileOutputStream
2,4,5
4,5
import
java.io.Serializable;
interface CardInfo
extends Serializable
{
public String
cardNo();
public String
cvvNo();
}
class CustomerInfo
implements
CardInfo {
public String
customerId;
public String
customerName;
public String
cardNo() { return
null; }
public String
cvvNo() { return
null; }
}
1,5
1
1
1,3,4
1,5
2
2
4,5
4,5
1,2,5
2,3,4
2345
1.4e99f
2.4e99f
3.4e99
3,5
1,5
3,5
1,5
2,4
public int
hashCode() {
return 1000+;
}
4,5
2,5
1,5
1,5
1,4,5
1,5
4,5
1,5
3,5
3,5
1,5
This cannot be
done, the class Task
should implement
Runnable
Keyboard
1
1
Playground
1
1
Iterable interface
added as super
interface for
java.util.Collection
SAX
1
1