Search Header Logo

Unit-1 Quiz2

Authored by Ms STAFF

Education

University

Used 2+ times

Unit-1 Quiz2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a static variable in Java?

A static variable is a variable that cannot be changed once initialized.

A static variable is a variable that is only accessible within the method it is declared.

A static variable is a method-level variable unique to each instance.

A static variable is a class-level variable shared among all instances of the class.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does a static variable differ from an instance variable?

A static variable is shared across all instances of a class, while an instance variable is unique to each instance.

A static variable can only be accessed within the class, while an instance variable can be accessed from outside the class.

A static variable is unique to each instance of a class, while an instance variable is shared across all instances.

A static variable is created every time an instance is created, while an instance variable is created only once.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Can a static variable be accessed without creating an object?

Static variables cannot be accessed from outside their class.

Yes, a static variable can be accessed without creating an object.

Static variables can only be accessed in the same class.

No, a static variable requires an object to be accessed.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What are the characteristics of a static method in Java?

Characteristics of a static method in Java include: belongs to the class, can be called without an instance, can access static variables/methods, cannot access instance variables/methods directly.

Can access both static and instance variables directly

Can only be called from an instance of the class

Belongs to an object rather than the class

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Can a static method access instance variables directly?

Yes, a static method can access instance variables directly.

No, a static method cannot access instance variables directly.

Static methods can access instance variables through an object reference.

Static methods can modify instance variables directly.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a static block in Java?

To initialize static variables or perform actions at class loading time.

To handle exceptions that occur during class loading.

To define methods that can be called without creating an instance of the class.

To create a new instance of a class when it is loaded.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main difference between String and StringBuffer in Java?

StringBuffer is faster than String for all operations.

String can be modified after creation while StringBuffer cannot.

String is used for character data while StringBuffer is used for numeric data.

The main difference is that String is immutable while StringBuffer is mutable.

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?