Search Header Logo

JAVA 2

Authored by Nagendrapatel Puppala

Arts

1st Grade

Used 4+ times

JAVA 2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following program?

public class Test implements Runnable {

    public void run() { System.out.printf("%d", 3); }

    public static void main(String[] args)

        throws InterruptedException

    {

        Thread thread = new Thread(new Test());

        thread.start();

        System.out.printf("%d", 1);

        thread.join();

        System.out.printf("%d", 2);

    }

}

123

213 or 231

132 or 312

321

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following program? 

public class Test

{

    private static int value = 20;

    public int s = 15;

    public static int temp = 10; 

    public static class Nested

    { 

      private void display()

      {

          System.out.println(temp + s + value);

      } 

    } 

      

    public static void main(String args[])

    { 

      Test.Nested inner = new Test.Nested(); 

      inner.display(); 

    }

}

Compilation error

1020

101520

NONE

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following program? 

import java.io.*;

public class Test

{

    public void display() throws IOException

    {

        System.out.println("Test");

    }

 

}

 

class Derived extends Test

{

    public void display() throws IOException

    {

        System.out.println("Derived");

    }

    public static void main(String[] args) throws IOException

    {

        Derived object = new Derived();

        object.display();

    }

}

Test

Derived

Compilation error

Runtime error

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the Output of the following Java Program?

import java.util.LinkedList;

 

class Demo {

public void show()

    {

        LinkedList<String> list = new LinkedList<String>();

 

        System.out.println(list.getClass());

    }

} public class Main {

public static void main(String[] args)

    {

        Demo demo = new Demo();

        demo.show();

    }

}

class java.util.LinkedList 

String 

Compiler Error 

NULL

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following program? 

Java

public class Test extends Thread

{

    public void run()

    {

        System.out.printf("Test ");

    }

    public static void main(String[] args)

    {

        Test test = new Test();

        test.run();

        test.start();

    }

}

compile time error

runtime error

Test

Test Test

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

For the given code select the correct answer. public interface Test

{

    public int calculate();

    protected interface NestedInterface

    {

        public void nested();

    }

}

Compile time error due to NestedInterface

Compile time error due to access modifier of NestedInterface

No Compile time error

NestedInterface cannot hold any function declaration.

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following program?

public class Test {

public     static void main(String[] args)

    {

        int[] arr = { 1, 2, 3, 4, 5 };

        System.out.println(arr);

    }

}

1

Compile-time error 

12345

[I@Hashcode_in_Hexadecimal 

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?