Are you reading to get your java certification test? There are different things that you need to understand to ensure you do not fail the test properly, and the programming trivia questions quiz below will help you get a clue of what they are. How about you give it a shot and get to see if you actually know enough See moreto sit for the test or need more study hours.
A main method must be declared in every class.
A package must contain more than one class.
A subclass can inherit from a superclass.
Objects cannot be reused.
Object can share behaviors with other objects.
Object is the root class of all other objects.
Rate this question:
Improves the program structure because exceptions must be handled in the method in which they occurred.
Provides a set of standard exceptions that covers all the possible errors.
Improves the program structure because the error handling code is separated from the normal program function.
Improves the program structure because the programmer can choose where to handle exceptions.
Allows the creation of new exceptions that are tailored to the program being created.
Rate this question:
At line n1 insert: public CheckingAccount(){ acct.amount = 100; }
At line n1 insert: public CheckingAccount(){ this.amount = 100; }
At line n1 insert: public CheckingAccount(){ amount = 100; }
At line n2 insert: acct.amount = 100;
At line n2 insert: amount = 100;
Rate this question:
1 2 3 4 followed by an ArrayIndexOutBoundsException
1 2 3
1 2 3 4
Compilations fails.
Rate this question:
Reading Card Checking Card
Compilation fails only at line n1.
Compilation fails only at line n3.
Compilation fails at both line n2 and line n3.
Rate this question:
10 : 30 : 5
10 : 22 : 22
10 : 22 : 20
10 : 22 : 5
Rate this question:
1 3 5 7 1 3
1 3 1 3
1 3 1 3 0 0
Compilation fails.
1 3 Followed by an ArrayIndexOutOfBoundsException.
Rate this question:
Welcome Log 1: 0
Welcome Log 2: 1
Hello Log 2: 1
Hello Log 1: 0
Rate this question:
Hello Java SE 8 Hello Java SE 8
Hello java.lang.StringBuilder@<<hashcode>> Hello p1.MyString@<<hashcode2>>
Hello Java SE 8 Hello p1.MyString@<<>hashcode>
Compilation fails at the Test class.
Rate this question:
String main 1
Int main 1
Object main 1
Compilation fails.
An exception is thrown at runtime.
Rate this question:
Java MyFile 0 1 2 3
Java MyFile 1 3 2 2
Java MyFile 1 2 2 3 4
Java MyFile 2 2 2
Rate this question:
An UnsupportedOperationException is thrown at runtime.
Hi removed
Compilation fails.
The program compiles, but it prints nothing.
Rate this question:
All subclasses of the Exception class except the RuntimeException class are checked exceptions.
The parameter in a catch block is of Throwable type.
All subclasses of the RuntimeException class are recoverable.
All subclasses of the RuntimeException class must be caught or declared to be thrown.
All subclasses of the Error class are checked exceptions and are recoverable.
Only Unchecked exceptions can be rethrown.
Rate this question:
Stuff.equals("TV") ? res = "Walter" : stuff.equals("Movie") ? res = "White": res = "No Result";
Res = stuff.equals("TV") ? "Walter" else stuff.equals("Movie") ? "White": "No Result";
Res = stuff.equals("TV") ? stuff.equals("Movie") ? "Walter" : "No Result";
Res = stuff.equals("TV") ? "Walter" : stuff.equals("Movie") ? "White": "No Result";
Rate this question:
10 Hello Hello 121
10 Hello 11
10 Hello 12
10 Hello Hello 11
Rate this question:
4W 150 Manual 4W 150 Auto
Compilation fails in line n1.
4W 150 Auto 4W 150 Manual
Compilation fails in line n2.
Rate this question:
2014-09-30
2014-07-31
07-31-2014
An exception is thrown at runtime.
Rate this question:
StringBuilder sb = new StringBuilder(x); sb.append(creditCard, 15, 19); return sb.toString();
StringBuilder sb = new StringBuilder(creditCard); sb.subString(creditCard, 15, 19); return x + sb;
return x + creditCard.substring(15, 19);
StringBuilder sb = new StringBuilder(creditCard); StringBuilder s = sb.insert(0, x); return s.toString();
Rate this question:
Error class is unextendible.
Error is a RuntimeException.
Error is an Exception.
Error is a Throwable.
Error class is extendable.
Rate this question:
Static int[] findMax(int max)
Static int findMax(int[] numbers)
Final int[] findMax(int [] a)
Public int findMax(int[] numbers)
Rate this question:
The main method can be overloaded.
A class must be kept in a package to compile and run successfully.
A class must contain at least an instance variable declaration and an empty constructor.
The Object class is the root of the class hierarchy.
A main method must be declared in the class.
A top-level class can be declared with the access modifiers private, public or protected.
Rate this question:
while (idx <= size - 1){ idx++; }
do { idx++; } while (idx <= size);
while (idx < size) { idx++; }
do { idx++; } while (idx >= size);
do { idx++; } while (idx < size -1);
Rate this question:
True, true
True, false
False, true
False, false
Rate this question:
Change the setArea methods to private.
Change the area field to public.
Call the setArea method at the beginning of the setLenght method.
Call the setArea method at the end of the setLenght method.
Call the setArea method at the beginning of the setHeight method.
Call the setArea method at the end of the setHeight method.
Rate this question:
A DateTimeException is thrown at runtime.
Compilation fails.
2012-02-10
2012-02-11
Rate this question:
5 : 5
10 : 10
5: 10
Compilation fails.
Rate this question:
2 4
0 2 4 6
0 2 4
Compilations fails.
Rate this question:
while (x >= 0) { System.out.print(array[x]); x--; }
do { x--; System.out.print(array[x]); } while ( x >= 0);
do { System.out.print(array[x]); --x; } while (x >= 0);
while(x > 0) { x--; System.out.print(array[x]); }
while (x > 0 ) { System.out.print(array[--x]); }
Rate this question:
Compilations fails.
0 Found
1 Found
3 Found
Rate this question:
Compilations fails at line n2.
Compilations fails at line n1.
Throw a ClassCastException at Runtime at line n2.
Throw a ClassCastException at Runtime at line n1.
A A
A C
Rate this question:
Invalid Names omas null null
Invalid Names
Invalid Names omas
Omas
Rate this question:
Compilation fails.
-1
4
3
Rate this question:
3 5
9 25
0 0
Compilation fails.
Rate this question:
Compilation fails.
10 20 30 40
0 0 30 40
An exception is thrown at runtime.
Rate this question:
Int f = ps.indexOf(new Patient("Mike"));
Int f = ps.indexOf(Patient("Mike"));
Patietn p = new Patient("Mike"); int f = ps.indexOf(p);
Int f = ps.indexOf(p2);
Rate this question:
final abstract class A5{ protected static int i; void doStuff(){} abstract void doIt(); }
abstract class A3{ private static int i; public void doStuff(){} public A3(){} }
final class A1{ public A1(){} }
public class A2{ private static int i; private A2(){} }
class A4{ protected static final int m; private void doStuff(){} }
Rate this question:
Javac Greeting java Greeting Duke
Javac Greeting.java Duke java Greeting
Javac Greeting.java java Greeting Duke
Javac Greeting.java java Greeting.class Duke
Rate this question:
Compilation fails at both n1 and line n2.
Compilation fails at line n1.
Compilation fails at line n2.
Rtool::export
Tool::export
Rate this question:
4 21
4 5
5 4
3 5
4 4
4 4
4 7
4 7
Rate this question:
Sb.deleteAll();
Sb.delete(0,sb.length());
Sb.delete(0,sb.size());
Sb.removeAll();
Rate this question:
if (qty >= 90){ discount = 0.5; } if (qty > 80 && qty <90){ discount = 0.2; }
discount = (qty >= 90) ? 0.5 : 0 ; discount =(qty > 80) ? 0.2 : 0;
discount = (qty >=90 )? 0.5 : (qty > 80)? 0.2 : 0;
if(qty > 80 || qty <90){ discount = 0.2; }else{ discount = 0; } if(qty >= 90){ discount = 0.5; } else{ discount = 0; }
Rate this question:
Replace line 5 with String opt = "true"; Replace line 7 with case "true":
Replace line 5 with String opt = 1; Replace line 7 with case 1:
At line 9, remove the break statement.
Remove the default section.
Rate this question:
10 : 0
0 : 0
Compilation fails on line n1.
Compilation fails on line n2.
Compilation fails on line n3.
Rate this question:
200: 300 200: 300
300: 0 0: 300
300: 300 200: 300
300: 100 200: 300
Rate this question:
An exception is thrown at runtime.
-1
5
0
Rate this question:
C2c2
C1c2
Compilations fails.
Thrown an exception at runtime.
Rate this question:
Thrown an exception at runtime.
Richard Donald
Null Richard Donald
Compilation fails.
Rate this question:
Welcome Visit Count: 1 Welcome Visit Count: 2
Welcome Visit Count: 1 Welcome Visit Count: 1
Compilation fails at line n1 and line n1 and line n2.
Compilation fails at line n3 and line n3 and line n4.
Rate this question:
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.
Wait!
Here's an interesting quiz for you.