Unit-1 Quiz2

Unit-1 Quiz2

University

15 Qs

quiz-placeholder

Similar activities

Java basic final

Java basic final

University

20 Qs

Java

Java

12th Grade - University

10 Qs

Round 2

Round 2

University

15 Qs

Java day 2

Java day 2

University

15 Qs

java day 3

java day 3

University

14 Qs

CS8592-OOAD-UNIT II- QUIZ III

CS8592-OOAD-UNIT II- QUIZ III

University

20 Qs

C Programming - Quiz

C Programming - Quiz

University

20 Qs

Estructuras de Datos en Python

Estructuras de Datos en Python

University

15 Qs

Unit-1 Quiz2

Unit-1 Quiz2

Assessment

Quiz

Education

University

Medium

Created by

Ms STAFF

Used 2+ times

FREE Resource

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.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?