Search Header Logo

Java

Authored by Subba Chavva

Computers

University

Used 1+ times

Java
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a class in object-oriented programming?

A variable that holds multiple values

A type of exception handling mechanism

A blueprint for creating objects

A method that performs calculations

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does encapsulation mean in Java?

Hiding the implementation details of a class

Creating multiple instances of a class

Using class inheritance

Combining multiple classes into one

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which Java feature allows a subclass to inherit properties and behaviors from a superclass?

Encapsulation

Polymorphism

Abstraction

Inheritance

4.

FILL IN THE BLANK QUESTION

1 min • 1 pt

What is the output of the following Java program?

public class MyClass {

    int x;

    public MyClass(int val) {

        x = val;

    }

    public static void main(String[] args) {

        MyClass obj = new MyClass(5);

        System.out.println(obj.x);

    }

}

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements correctly initializes an array of integers in Java?

int[] numbers = new int[5]();

int[] numbers = new int[5];

int numbers[5];

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

6.

FILL IN THE BLANK QUESTION

1 min • 1 pt

What is the output (value only) of the following Java program?

public class Circle {

    double radius;

    public Circle(double r) {

        radius = r;

    }

    public double calculateArea() {

        return Math.PI radius radius;

    }

    public static void main(String[] args) {

        Circle c = new Circle(3.0);

        System.out.println( c.calculateArea());

    }

}

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access the third element of an array named scores?

scores.get(3)

scores.third

scores[2]

scores(3)

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?

Discover more resources for Computers