The Java programming language is a high-level language. In the Java programming language, all source code is first written in plain text files which then compiled into "class files" by the javac compiler. The compiled files does not contain code that is native to a specific processor; it instead contains byte codes (the machine language of the Java Virtual Machine (Java VM). The java launcher tool then runs the application with an instance of the Java Virtual Machine. Because the Java VM is available on many different operating systems, the same compiled files (class files) are capable of running on any Operating System (e.g. Linux, Windows).
True/false question
In Java, if a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass at the end of the constructor.
True or False?
| Questions: | 2 |
| Attempts allowed: | Unlimited |
| Available: | Always |
| Pass rate: | 75 % |
| Backwards navigation: | Allowed |
Take a basic Java quiz. Test your knowledge in Java.
Start quiz
Multiple choice question
In Java, can Enum extends another Enum, so the new Enum will add more elements to another Enum?
Multiple choice question
Given the following, what will be the output?
public class TestA {
public TestA(){ }
public void test(){
String s = getClass().getSimpleName();
System.out.print(s);
}
}
public class TestB extends TestA{
public TestB(){ }
static public void main(String[] args){
TestA a = new TestA();
TestB b = new TestB();
a.test();
b.test();
}
}
Multiple choice question
What will be the output of the following Java code?
public class X
{
public static int A = 5;
public static void main(String[] args) throws Exception
{
X x = null;
System.out.println(x.A);
X[] array = new X[0];
System.out.println(array[-1].A);
}
}
True/false question
In java, static methods or members are not inherited (overridden) but they can be hidden.
True or False?
Example:
class A {
static int aStaticMember;
}
class B extends A{ }
Class C extends B{
public static void main(String[] S){
System.out.println(A.aStaticMember);
A.aStaticMember++;
System.out.println(B.aStaticMember);
B.aStaticMember++;
System.out.println(C.aStaticMember);
}
}
Multiple choice question
With which modifiers, a top level class can be declared with?
Multiple choice question
Which of the following cases will result in run-time error?
True/false question
In Java, constructors cannot be synchronized.
True/false question
you can't override a static method with a non-static method. In other words, you can't change a static method into an instance method in a subclass.