Java

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).

Java minus sign

Multiple choice question

What will be the output of the following code part:

 Integer i = 34;
String s = "is my age";
String out = i + '-' + s;
System.out.println(out);

The Java compiler automatically inserts a call to the no-argument constructor

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?

Basic Java Quiz

Questions:3
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Backwards navigation:Allowed

Take a basic Java quiz. Test your knowledge in Java.

Start quiz

In Java, can Enum extends another Enum?

Multiple choice question

In Java, can Enum extends another Enum, so the new Enum will add more elements to another Enum?

Java getClass getSimpleName

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();
}
}

java maintains a single copy of static variable on heap

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);
}
}

Java Static Method overridden

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);
}
}

With which modifiers, a top level class can be ...

Multiple choice question

With which modifiers, a top level class can be declared with?

Java main method declaration

Multiple choice question

Which of the following cases will result in run-time error?

In Java, constructors cannot be synchronized.

True/false question

In Java, constructors cannot be synchronized.

Syndicate content