JAVA is everywhere, from your microwave oven to DVD player, TV remotes to music players, almost everywhere JAVA is used. Well, cut to short, Core Java focuses on the language basics such as data structures, data types, operators, control statements, string handling, exception handling, etc. Here in this quiz, you will face forty-five questions of the same. So, let's get See morestarted.
StringBuffer is extended from String class
StringBuffer is threadsafe
'capacity' property indicates the maximum number ofcharacters that a StringBuffer can have
StringBuffer implements Charsequence interface
Buffer space in StringBuffer can be shared
Rate this question:
Output of Line a and Line b will be same
Output of Line a and Line b will be different
Line a prints the corresponding classname with Object'shashcode in Hexadecimal
Both Line a and Line b will print the corresponding classnamewith Object's hashcode in Hexa Decimal
Both Line a and Line b prints "Shatapdhi"
Rate this question:
PreparedStatement are the SQL templates available in thedatabase server, that can be used directly without writingcomplex SQL code
PreparedStatement cannot be used to create ScrollableResultSet
Parameters can be passed to PreparedStatement at run-time
PreparedStatements are precompiled SQL statements thatare faster in execution
PreparedStatement is the sub interface of Statementinterface
Rate this question:
Hello Hello world
World world world
Hello Hello Hello
World Hello Hello
Hello world Hello
Rate this question:
The variable at line 4 should be declared as final
The variable at line 2 should be declared as final
The method at line 6 should be defined as final method
The inner class Circle 2 should be an abstract class
The object for the inner class Circle2 should be created in main() method
Rate this question:
Transforms s1 into the union of s1 and s2
Transforms s1 into the intersection of s1 and s2.
Returns true if s2 is a subset of s1
Transforms s1 into the (asymmetric) set difference of s1 ands2
Copies elements from s2 to s1
Rate this question:
A new synchronized object need to be created for every oneto-one personal messaging request from the user
The personal messaging feature cannot be added when thereis a general room facility
A part of the synchronized object that already exists for thegeneral room can be used
Just two more threads need to be created at the user end
Rate this question:
5th element of an array is accessed, whose size is 3
A file that actually does not exist, is opened for reading
An attempt to connect to the database is made but failed.
Length() method is called on a String object, that is assignedto null
Given username and password is checked with database andfound invalid
Rate this question:
To call the sleep() method, a thread must own the lock of theobject which the call is to be made.
To call the join() method, a thread must own the lock of theobject on which the call is to be made
To call the wait() method, a thread must own the lock of theobject on which the call is to be made.
To call the yield() method, a thread must own the lock of theobject on which the call is to be made.
To call the wait() method, a thread must own the lock of thecurrent thread.
Rate this question:
Noise
Bark
Meow
Compilation fails
An exception is thrown at runtime
Rate this question:
Grts = new float[1][4];
Invt = grts;
Hms = new float[2][5];
Invt = new float[4][2];
Grts = new float[1];
101020
1020
1010
Compilation Error
3014
Rate this question:
Polymorphism
Abstraction
Inheritance
Reusability
Rate this question:
None of the listed options
S
H
Space
Rate this question:
Prints: A.m1, A.m2, A.m3, A.m4,
Compile-time error at 3.
Compile-time error at 4.
Compile-time error at 2.
Compile-time error at 1.
Rate this question:
New HashSet(c);
All of the listed options
New LinkedTreeSet(c);
New LinkedHashSet(c);
Rate this question:
NavigableSet
NavigableList
NavigableMap
Deque
Rate this question:
Public
Final
Abstract
Private
Protected
Rate this question:
A class can have more than one instance block
An instance block cannot initialise the class members
Instance blocks are executed only when the instances arecreated from main() method of that class
Instance blocks are executed before constructors
Instance blocks are executed for every created instance
Rate this question:
Interface author{@String name(),String date()}
@interface author{@String name();@String date();}
Interface author{String name(),String date()}
Interface @author{String name(),String date()}
@interface author{String name();String date();}
Rate this question:
Runtime Error "IllegalThreadStateException"
Compile-time Error
Prints the following output 2 times: Planet (waits for 1000 milli seconds) Earth
Prints the following output: Planet Planet (get into long wait. Never ends)
Prints the following output 1 time: Planet (waits for 1000 milli seconds) Earth
Rate this question:
Polymorphism
Association
Inheritance
Aggregation
Persistence
Rate this question:
Throws a compile time exception as overridden method a() does not throw exception smile
Welcome class two
Two
Throws a compile time exception as overridden method z() does not throw exception smile
Class two
Rate this question:
One two
Two one
Compilation fails. Cannot use super keyword inside an anonymous class
Runtime exception. Cannot find the super class version of show() method
Rate this question:
Welcome
Welcome Planet
Compilation fails
The code runs with no output
Welcome Planet 5
Rate this question:
If run with no arguments, the program will print "The end"
If run with one argument, the program will print the given argument followed by "The end"
If run with one argument, the program will simply print the given argument
The program will throw an ArrayIndexOutOfBoundsException
If run with no arguments, the program will produce no output
Rate this question:
Four
One
None of the objects are eligible
Two
Three
Rate this question:
FileInputStream and PipedInputStream
FileInputStream and InputStreamReader
InputStreamReader and FilterInputStream
FileInputStream and SearchInputStream
FileReader and BufferedReader
Rate this question:
Created Program.txt
Created Program
Created Program.java
Created Program.java.txt
Rate this question:
Reads the text from keyboard line by line and prints the same to the console on pressing ENTER key at the end of every line, then the same is flushed (erased) from the console.
Reads the text from keyboard line by line and prints the same to the console on pressing ENTER key at the end of every line
Reads the text from keyboard and prints the same to the console on pressing Ctrl Z, flushes (erases) the same from the console.
Reads the text from keyboard and prints the same to the console on pressing Ctrl Z
Reads the text from keyboard character by character and prints the same to the console on typing every character.
Rate this question:
Compile-time error: Integer wrapper cannot accept char type
Prints: EQ
Compile-time error: Wrapper types cannot be compared using equals
Prints: equals EQ
Prints: equals
Rate this question:
A program can suggest that garbage collection be performed but not force it
An object becomes eligible for garbage collection when all references denoting it are set to null
None of the listed options
Garbage collection is platform independent
The automatic garbage collection of the JVM prevents programs from ever running out of memory
Rate this question:
New elements are added and old ones are taken out but size is increasing
New elements are added and old ones are taken out but there will be a change in size
No change because we are adding and deleting the same element
New elements are added and old ones are taken out but no change in size
New elements can be added but cannot be removed
Rate this question:
Compilation Error 'Cannot pass null as method arguments'
Prints: String
Throws NullPointerException at runtime
Prints: Object
Rate this question:
ClassCastExceprion will be thrown.
@Override cannot be used for equals() method.
Compile error: class doesn't override a method from it's superclass @Override.
Program compiles sucessfully and executes.
Rate this question:
The code is wrong. Exceptions should be caught in reversed hierarchy order.
Line 1 : throw new Exception(); Line 2 : throw new IOException(); Line 3 : throw new FileNotFoundException();
Line 1 : throw new IOException(); Line 2 : throw new FileNotFoundException(); Line 3 : throw new Exception();
Line 1 : throw new IOException(); Line 2 : throw new IOException(); Line 3 : throw new IOException();
Line 1 : throw new FileNotFoundException(); Line 2 : throw new IOException(); Line 3 : throw new Exception();
Rate this question:
Queen king
King queen
Compilation fails.
MyThread king
MyThread queen
Rate this question:
Go();
New Choco(). new Bar().go();
(new Bar() {}).go();
New Bar().go();
New Choco().go();
Rate this question:
CallableStatement
DriverManager
Connection
Statement
SQLWarning
Rate this question:
Compiles and Executes with no output
Welcome Planet
Planet Welcome
Planet
Compilation Error
Rate this question:
Prints: -2.0
Prints: 10.3
Prints: 12.3
Prints: 0.0
Rate this question:
True
False
Rate this question:
True
False
Rate this question:
DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try { Date d = df.parse(dob); } catch(ParseException pe) { }
GregorianCalendar g = new GregorianCalendar(dob); Date d = g.getDate();
Date d = new Date(dob);
CalendarFormat cf = new SimpleCalendarFormat("dd/MM/yyyy"); try { Date d = cf.parse(dob); } catch(ParseException pe) { }
Calendar c = new Calendar(dob); Date d = g.getDate();
Rate this question:
Quiz Review Timeline (Updated): Mar 21, 2023 +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.
Wait!
Here's an interesting quiz for you.