This 'java core mock test 4' assesses knowledge on Java core concepts such as exception handling, interfaces, abstract classes, and inheritance. It is designed to test understanding of code snippets, error identification, and object serialization, essential for developers and programmers.
A. true
B. Welcome Planet
C. Compile-time error
D. false
Run time error
Rate this question:
A. Compile-time error
B. false false
C.true false
D.true true
E.false true
Rate this question:
A. Line 1: public void m1() throws IOException Line 2: public void m1() throws FileNotFoundException Line 3: public void m1() throws Exception
B. Line 1: public void m1() throws Error Line 2: public void m1() throws Exception Line 3: public void m1() throws Throwable
C. Line 1: public void m1() throws NoClassDefFoundError Line 2: public void m1() throws Error Line 3: public void m1()
D. Line 1: public void m1() throws NullPointerException Line 2: public void m1() throws RuntimeException Line 3: public void m1() e. Line 1: public void m1()
E. Line 1: public void m1() Line 2: public void m1() Line 3: public void m1()
Rate this question:
A.Cloneable interface
B. Writable interface Writable interface
C. Readable interface
D. Serializable interface
E. ObjectSerializable interface
Rate this question:
A. class A { int v; public String sayHello() { return "Hello"; }public class B extends A { public int sayHello(int a) { return 3 + a; } } }
B. class A { int v; public String sayHello() { return "Hello"; } } class B { A a; public String sayHello() { return "Hello from B"; } }
C. class A { int v; final String sayHello() { return "Hello"; } } class B extends A { public int sayHello(int a) { return 3 + a; } }
D. class A { int a; public String methodA(String s) { String var = "My App" + s; return var; } } class B extends A { public String methodA(String s) { String bar = "Bar" + s; return bar; } }
E. interface MyInterface { public void myMethod(String s); } class A implements MyInterface { public void myMethod(String s) { // Some Implementation } }
A. Runtime Error
B. Inside showMethod. followed by caught: b.java.lang.IllegalAccessException: exception
C. Compiles successfully, nothing is printed
D. Compilation Error
Rate this question:
A. No special precautions need be taken
B. Any method calling X must use try-catch, specifically catching FileNotFoundException
C. The method X must be declared as throwing FileNotFoundException
D. The method X must be declared as throwing IOException or Exception 26 Consider the following code: class A
E. Can contain Nulls
A. Deqeue
B. Queue
C. Stack
D. NavigableSet
E. NavigableMap
Rate this question:
A. the elements are ordered
B. the elements are sorted
C. cannot contain NULLs
D. the elements are NOT ordered
Rate this question:
A. throw new Error();
B. throw new Throwable();
C. throw new ExceptionOneOne();
D. throw new Exception();
E. throw new ExceptionOneTwo();
Rate this question:
A. public class Employee implements Info extends Data { public void load(){ /*do something*/ } public void Info.load(){ /*do something*/ } }
B. public class Employee extends Info implements Data { public void load() { /*do something*/ } }
C. public class Employee implements Info extends Data { public void Data.load(){ /*do something*/ } public void load(){ /*do something*/ } }
D. public class Employee implements Info extends Data { public void load() { /*do something*/ } }
E. public class Employee extends Info implements Data public void load(){ /*do something*/ } public void Info.load(){ /*do something*/ } } 10\
A. 10 10
B. Compilation Error. Duplicate identifer ID found
C. 20 20
D. 10 20
E. 20
Rate this question:
A. Subclasses of Exceptions can be caught using try-catch
B. Error type objects can be handled only by JVM
C. Error is the subclass of Exception
D. Subclasses of Error are unchecked
E. Subclasses of Throwable can be caught using try-catch
Rate this question:
A. DBMetaData
B. MetaData
C. DatabaseMetaData
D. ResultSetMetaData
E. SchemaMetaData
Rate this question:
A. DriverManager
B. CallableStatement
C. Connection
D. Statement
E. SQLWarning
Rate this question:
A. the Set of key-value pairs contained in the Map
B. The Collection of values contained in the Map
C. It is an inner interface inside Map interface
D. the Set of keys contained in the Map
Rate this question:
A. Line 1 : throw new FileNotFoundException(); Line 2 : throw new IOException(); Line 3 : throw new Exception();
B. Line 1 : throw new Exception(); Line 2 : throw new IOException(); Line 3 : throw new FileNotFoundException();
C. The code is wrong. Exceptions should be caught in reversed hierarchy order.
D. Line 1 : throw new IOException(); Line 2 : throw new IOException(); Line 3 : throw new IOException();
E. Line 1 : throw new IOException(); Line 2 : throw new FileNotFoundException(); Line 3 : throw new Exception(); 43 Consider the following program: class A extends Thread { public void run() {System.out.print("A");} } class B
Rate this question:
A. runtime error
B. Catchable caught null pointer exception null pointer exception
C. null pointer exception null pointer exception Catchable caught
D. compile-time error
E. null pointer exception Catchable caught null pointer exception
Rate this question:
A. Inheritance is a kind of Encapsulation
B. Inheritance enables adding new features and functionality to an existing class without modifying the existing class
C. In an inheritance hierarchy, a subclass can also act as a super class
D. Inheritance does not allow sharing data and methods among multiple classes
E. In an inheritance hierarchy, a superclass can also act as a sub class
Rate this question:
Public abstract class Canine{ public Bark speak(); }
Public abstract class Canine{ public Bark speak(); {} }
Public abstract Canine {public abstract Bark speak(); }
Public class canine abstract { public abstract Bark speak); }
Rate this question:
A. ResultSet.TYPE_SCROLL_SENSITIVE
B. ResultSet.TYPE_SCROLLABLE
C. ResultSet.TYPE_SCROLL_INSENSITIVE
D. ResultSet.TYPE_FORWARD_ONLY
E. ResultSet.TYPE_SCROLL_BIDIRECTIONAL
Rate this question:
A. Compiles successfully, nothing is printed
B. Compilation Error
C. Runtime Error
D. Inside showMethod. followed by caught: java.lang.IllegalAccessException: exception
Rate this question:
A. a SortedSet extended with navigation methods for Maps.
B. a SortedSet extended with navigation methods for Lists.
C. a new class implementation of Set which can navigate the ResultSet object
D. a SortedSet extended with navigation methods reporting closest matches for given search targets.
A. No compilation error but throws RuntimeException on running the code
B. Compilation error at line 10
C. Compilation error at line 14
D. Compilation error at line 5
E. Compilation error at line 6
Rate this question:
A. Polymorphism
B. Inheritance
C. Abstraction
D. Reusability
Rate this question:
A. Compiles successfully, nothing is printed
B. Compilation Error
C. Runtime Error
D. Inside showMethod. followed by caught: java.lang.IllegalAccessException: exception
Rate this question:
A. 10 10
B. 10 20
C. Compile time error. Incompatible Type conversion.
D. 20 10
E. 20 20
Rate this question:
A. 5th element of an array is accessed, whose size is 3
B. A file that actually does not exist, is opened for reading
C. An attempt to connect to the database is made but failed.
D. length() method is called on a String object, that is assigned to null
E. Given username and password is checked with database and found invalid
Rate this question:
A. single inheritance
B. double inheritance
C. multiple inheritance
D. class inheritance
Rate this question:
A.true
B.false
Rate this question:
1. The thread that has been waiting the longest.
2. The thread that was the last one to to exit the monitor.
You can never be sure which thread will get to run first.
4. The the first thread that called the wait() method
A.Errors
B.Exceptions
C.Both Errors and Exceptions
Neither
Rate this question:
A.No. You can write a program to catch just the exceptions you want.
B. No. But if a program catches one type of exception it must catch all other types as well.
C. Yes. If a program is not written to catch all exceptions it will not compile.
D. Yes. A program can not do I/O unless it catches all exceptions.
Rate this question:
A.ArithmeticException
B. RunTimeException
C. NumberFormatException
D. NumberError
Rate this question:
A. This is not legal, so the program will not compile.
B. The method throws the exception to its caller, exactly if there were no try{} block.
C. The program halts immediately.
D. The program ignores the exception.
Rate this question:
A. The type of the object.
B. The type of the reference variable.
Rate this question:
No—if a class defines an abstract method the class itself must be abstract.
No—only classes are abstract, not methods.
Yes—a method can be declared abstract in any parent as long as the child classes also declare it abstract.
Yes—there is no restriction on where abstract methods can be defined.
Rate this question:
No—it must have all one or the other.
No—it must have all abstract methods.
Yes—but the child classes do not inherit the abstract methods.
Yes—the child classes inherit both.
Rate this question:
A.valentine
B.birthday
C.holiday
D.card
Rate this question:
Quiz Review Timeline (Updated): Dec 7, 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.