This Core Java mock test assesses knowledge of Java's access modifiers, inheritance, array initializations, and method overriding. It is designed to enhance understanding of Java programming principles and prepare learners for advanced Java topics.
A member declared as ‘public’ CAN be accessed from ‘Other packages’.
A member declared with ‘protected’ access modifier CAN be accessed by the members of the ‘subclass’.
A member declared with ‘protected’ access modifier CANNOT be accessed by the members of the ‘Other package’.
A member declared with ‘Default’ access modifier CANNOT be accessed by the members of the ‘subclass’.
Rate this question:
True
False
Rate this question:
Prints: 0,0,0,null
Run-time error
Prints: 0,0,0.0,null
Compile-time error 12 Consider the following code snippet: interface i1 { int i = 0; } interface i2 { int i = 0; } class inter implements i1, i2 { public static void main(String[] a) { System.out.println(i); } } Which of the following options will be the output of the above code snippet? Answer: a. Runtime
Final
Default (blank), that is, the method declaration would read void setWidth( int n )
Protected
Private
Public
Rate this question:
Return types
Parameters of functions
Datatypes of parameters
Properties
Rate this question:
Abstract class Class2 implements Base {}
Abstract class Class2 extends Base { public boolean m1(){ return true; }}
Abstract class Class2 implements Base { public boolean m1(){ return (7 > 4); }}
Abstract class Class2 implements Base { protected boolean m1(){ return (5 > 7) }}
Rate this question:
Test( )
Public Test( )
Test(void)
Public Test(void)
Rate this question:
Private void eat()
Public void eat()
Public void eat() throws Exeption
Public String eat()
Rate this question:
New Inner(); //At line 5
New Inner(); //At line 10
New ot.Inner(); //At line 10
New Outer.Inner(); //At line 10
Rate this question:
Final
Private
Protected
Default
Rate this question:
Runtime exception
Throws ClassCastExeption
Throws NullPointerException
No error, will compile.
Rate this question:
True
False
Rate this question:
Public int method1(int a, int b) {return 0; }
Private int method1(int a, int b) { return 0; }
Public short method1(int a, int b) { return 0; }
Static protected int method1(int a, int b) { return 0; }
Rate this question:
Protected int a;
Transient int b = 3;
Private synchronized int e;
Volatile int d;
Rate this question:
Java Myfile 222
Java Myfile 1 2 2 3 4
Java Myfile 1 3 2 2
Java Myfile 0 1 2 3
Rate this question:
Overloaded methods must change the argument list
Overloaded methods can change the argument list
Overloaded methods can change the return type
Overloaded methods must change the return type
Overloaded methods can delare new or broader checked exceptions
Rate this question:
Dostuff method is not overridden
Subclass bar overrides the dostuff() method
Dostuff method is not overloaded.
IOException an not be inserted in the overloading method.
Rate this question:
Compilation fails at TestDirector class
Prints: Director Manirathnam also produces films
Prints: Director Manirathnam directs films Director Manirathnam also produces films
Prints: Director Manirathnam directs films
Rate this question:
Protected
Final
Abstract
Public
Rate this question:
A. transforms s1 into the union of s1 and s2
Transforms s1 into the intersection of s1 and s2.
Transforms s1 into the (asymmetric) set difference of s1 and s2
Copies elements from s2 to s1
Rate this question:
A. Test(3) Test(2) Test(1)
Test(2) Test(1) Test(3)
Test(1) Test(2) Test(3)
Test(1) Test(3) Test(2)
Rate this question:
18 20
17 18
19 17
17 17
Rate this question:
Inheriting from two super classes
Inheriting from a class which is already in an inheritance hierarchy
Inheriting from more than one super class
Inheriting from a single class
Rate this question:
True
False
Rate this question:
Public void add(A a) { a.getValue(); }
Public void add(B b) { b.getValue(); }
Public void add(C c1, C c2) { c1.getValue(); }
Public void add(C c) { c.getValue(); }
Public void add(A a, B b) { a.getValue(); }
Rate this question:
Compilation Error
Compiles successfully and prints a value which is less than zero
Compiles successfully and prints a value which is equal to Integer.MIN_VALUE
Compiles successfully and prints a value which is equal to -Integer.MAX_VALUE
Compiles successfully and prints a value which is equal to Integer.MIN_VALUE + 1
Rate this question:
Association refers to a class reuses the properties and methods of another class
Association refers to an object composed of set of other objects
Association refers to binding of related data and behaviours into a single entity
Associations are bi-directional
In Associations, cardinality refers to the number of related objects
Rate this question:
Form feed character
Tab character
The dollar character
Space character
The underscore character
Rate this question:
Prints: A.m1, A.m2, A.m3, A.m4,
Compile-time error at 4.
Compile-time error at 3.
Compile-time error at 2.
Rate this question:
True
False
Rate this question:
Runtime error
Throw an Stackoverflowerror exception
Compilation fails
Syntax error.
Rate this question:
Class B should be declared public abstract
Class A should be declared public abstract
The print method in class B should refer the x as super.x
The member x in class A should be declared as protected
This() method call should be removed from the class A constructor
Rate this question:
The first line in the constructor must be call to super()
This() always means call to another constructor in another class
Super() always means call to another constructor in another class
There is no difference in using this() and super().
Rate this question:
Any class in the test package
Any class that extends Target outside the test package
Any class
Only the Target class
Any class that extends Target within the test package
Rate this question:
Quiz Review Timeline (Updated): Aug 6, 2024 +
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.