This Java programming language practice quiz assesses knowledge of interface implementation, exception handling, and class casting, among other topics. It is designed for learners looking to improve their Java skills and understand core concepts.
Alpha a = x;
Alpha a = x;
Foo f= (Delta)x;
Foo f= (Alpha)x;
Beta b = (Beta)(Alpha)x;
Rate this question:
The class is fully encapsulated.
The code demonstrates polymorphism.
The ownerName variable breaks encapsulation.
The cardlD and limit variables break polymorphism.
The setCardlnformation method breaks encapsulation.
Rate this question:
Test
Null
An exception is thrown at runtime.
Compilation fails because of an error in line 1.
Compilation fails because of an error in line 4.
Compilation fails because of an error in line 5.
Rate this question:
Shape s = new Shape(); s.setAnchor(10,10); s.draw();
Circle c = new Shape(); c.setAnchor(10,10); c.draw();
Shape s = new Circle(); s.setAnchor(10,10); s.draw();
Shape s = new Circle(); s->setAnchor(10,10); s->draw();
Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw();
class Man extends Dog { }
class Man implements Dog { }
Class Man { private BestFriend dog; }
Class Man { private Dog bestFriend; }
Class Man { private Dog }
Class Man { private BestFriend }
Rate this question:
public interface B extends A { }
public interface B implements A {}
Public interface B instanceOf A {}
Public interface B inheritsFrom A { }
Rate this question:
The time to find the value from HashMap with a Person key depends on the size of the map.
Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
Rate this question:
Final
Static
Native
Public
Private
Abstract
Protected
Rate this question:
2
3
1 2
2 3
1 2 3
Compilation fails.
Au exceptional is thrown at runtime.
Rate this question:
Foreach(x) System.out.println(z);
for(int z : x) System.out.println(z);
while( x.hasNext()) System.out.println( x.next());
For( int i=0; i< x.length; i++ ) System.out.println(x[i]);
Rate this question:
TestA
TestB
Compilation fails.
An exception is thrown at runtime.
Rate this question:
Double getSalesAmount() { return 1230.45; }
Public double getSalesAmount() { return 1230.45; }
private double getSalesAmount() { return 1230.45; }
Protected double getSalesAmount() { return 1230.45; }
Rate this question:
Compilation fails.
An exception is thrown at runtime.
doStuffx = 6 main x = 6
DoStuffx = 5 main x = 5
DoStuffx = 5 main x = 6
doStuffx = 6 main x = 5
Rate this question:
Foo { public int bar() { return 1; } }
New Foo { public int bar() { return 1; } }
NewFoo() { public int bar(){return 1; } }
New class Foo { public int bar() { return 1; } }
Rate this question:
The instance gets garbage collected.
The code on line 33 throws an exception.
The code on line 35 throws an exception.
The code on line 31 throws an exception.
The code on line 33 executes successfully.
Rate this question:
Compilation fails due to an error in line 23.
Compilation fails due to an error in line 29.
A ClassCastException occurs in line 29.
A ClassCastException occurs in line 31.
The value of all four objects prints in natural order.
Rate this question:
Locale loc = Locale.getLocale(); System.out.println(loc.getDisplayCountry() + “ “+ df.format(d));
Locale loc = Locale.getDefault(); System.out.println(loc.getDisplayCountry() + “ “ + df.format(d));
Locale bc = Locale.getLocale(); System.out.println(loc.getDisplayCountry() + “ “+ df.setDateFormat(d));
Locale loc = Locale.getDefault(); System.out.println(loc.getDispbayCountry() + “ “+ df.setDateFormat(d));
Rate this question:
public class Employee extends Info implements Data { public void load() { /*do something*/ } }
S
public class Employee implements Info extends Data { public void load() { /*do something*/ } } C. public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
public class Employee implements Info extends Data { public void Data.load() { /*d something */ } public void load() { /*do something */ } }
Public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
. public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
Rate this question:
public class Session implements Runnable, Clonable { public void run(); public Object clone(); }
. public class Session extends Runnable, Clonable { public void run() { / do something */ } public Object clone() { / make a copy */ } }
. public class Session implements Runnable, Clonable { public void run() { / do something */ } public Object clone() { /* make a copy */ } }
. public abstract class Session implements Runnable, Clonable { public void run() { / do something */ } public Object clone() { /*make a copy */ } }
Public class Session implements Runnable, implements Clonable { public void run() { / do something */ } public Object clone() { / make a copy */ } }
Rate this question:
public class Circle implements Shape { private int radius; }
Public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
Blic abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius; public void draw() {/* code here */} }
Public abstract class Circle implements Shape { private int radius; public void draw() { / code here */ } }
Rate this question:
Yen returns correct values.
Euro returns correct values.
An exception is thrown at runtime.
Yen and Euro both return correct values.
Compilation fails because of an error at line 25.
Compilation fails because of an error at line 30.
Rate this question:
Compilation fails.
The code compiles and the output is 2.
If lines 16, 17 and 18 were removed, compilation would fail.
If lines 24, 25 and 26 were removed, compilation would fail.
If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.
If lines 24, 25 and 26 were removed, the code would compile and the output would be 1.
Rate this question:
import com.sun.scjp.Geodetics; public class TerraCarta { public double halfway() { return Geodetics.DIAMETER/2.0; } }
Import static com.sun.scjp.Geodetics; public class TerraCarta { public double halfway() { return DIAMETER/2.0; } }
import static com.sun.scjp.Geodetics. *; public class TerraCarta { public double halfway() { return DIAMETER/2.0; } }
Package com.sun.scjp; public class TerraCarta { public double halfway() { return DIAMETER/2.0; } }
Rate this question:
import sun.scjp.Color.*;
Import static sun.scjp.Color.*;
Import sun.scjp.Color; import static sun.scjp.Color.*;
Import sun.scjp.*; import static sun.scjp.Color.*;
Import sun.scjp.Color; import static sun.scjp.Color.GREEN
Quiz Review Timeline (Updated): Mar 22, 2023 +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.
Informatics Practice Quiz: Exam!
The Informatics Practice Quiz: Exam assesses knowledge in Java programming, focusing on swing controls, operators, loops, and switch-case statements. It is designed to test...
Questions:
10 |
Attempts:
453 |
Last updated:
Mar 19, 2023
|
Java Online Quiz 2
Java Online Quiz 2 assesses knowledge on Java programming basics including data types, variable declarations, and initialization. It is designed for learners to validate their...
Questions:
10 |
Attempts:
422 |
Last updated:
Mar 21, 2023
|
Java Programming Quiz
An interesting Java programming quiz is here for you if you use Java programming or are learning this language. The quiz is not going to be easy in any way. The questions designed...
Questions:
15 |
Attempts:
4778 |
Last updated:
Jul 03, 2023
|
Java Quiz-1
Java Quiz-1 assesses foundational Java programming skills through multiple-choice questions. Topics include constructor behaviors, method definitions, and class hierarchies. Ideal...
Questions:
100 |
Attempts:
5440 |
Last updated:
Sep 18, 2023
|
|
Java Quiz: Test Your GK! Trivia
This Java Quiz tests general knowledge in Java programming, covering topics like data types, access modifiers, OOP concepts, and applets. It assesses key skills for understanding...
Questions:
10 |
Attempts:
1007 |
Last updated:
Mar 22, 2023
|
Can You Answer These Java Programming Questions? Trivia Quiz
Can you answer these java programming questions? There are a lot of people who think that they can never fail any question they are asked when it comes to java programming, and to...
Questions:
10 |
Attempts:
541 |
Last updated:
Mar 22, 2023
|
Wait!
Here's an interesting quiz for you.