3CSE2 Lab Day-7

3CSE2 Lab Day-7

University

10 Qs

quiz-placeholder

Similar activities

latihan 1 Fiber Optic

latihan 1 Fiber Optic

University

10 Qs

Computer Graphics

Computer Graphics

University

10 Qs

CS GAMES TRYOUTS- ctf section

CS GAMES TRYOUTS- ctf section

University

11 Qs

Ch 5 Pop up

Ch 5 Pop up

9th Grade - University

13 Qs

CSC305: TOPIC 1

CSC305: TOPIC 1

University

11 Qs

Java test #1 #ITsubbotnik 2019

Java test #1 #ITsubbotnik 2019

University - Professional Development

5 Qs

BuilderPattern

BuilderPattern

University

9 Qs

Network and Computer Attacks

Network and Computer Attacks

University

15 Qs

3CSE2 Lab Day-7

3CSE2 Lab Day-7

Assessment

Quiz

Computers

University

Medium

Created by

Sharfuddin Mohammed

Used 1+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary purpose of StringBuffer in Java?

The primary purpose of StringBuffer in Java is to provide a mutable sequence of characters for efficient string manipulation.

To create immutable strings in Java.

To store a fixed number of characters.

To provide a method for string comparison.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does StringBuilder improve performance over StringBuffer?

StringBuilder automatically manages memory allocation, unlike StringBuffer.

StringBuilder is synchronized, making it safer for multi-threaded environments.

StringBuilder improves performance over StringBuffer by being non-synchronized, reducing overhead in single-threaded environments.

StringBuilder uses more memory than StringBuffer, leading to slower performance.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method in StringTokenizer is used to check if there are more tokens?

getTokenCount

hasMoreTokens

nextToken

isTokenAvailable

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between StringBuffer and StringBuilder in terms of thread safety?

Both StringBuffer and StringBuilder are thread-safe.

StringBuffer is faster than StringBuilder.

StringBuffer is thread-safe; StringBuilder is not.

StringBuilder is thread-safe; StringBuffer is not.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you convert a StringTokenizer to an array of strings?

Convert the StringTokenizer to a List using Collections.list().

Use a loop to collect tokens into a List, then convert it to an array with list.toArray(new String[0]).

Use String.split() method directly on the string.

Call the toArray() method on the StringTokenizer instance.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What method would you use to append a string to a StringBuilder?

stringBuilder.insert("yourString");

stringBuilder.addString("yourString");

stringBuilder.concat("yourString");

stringBuilder.append("yourString");

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain how String manipulation can affect performance in Java applications.

String operations are faster than primitive data types.

String manipulation has no impact on performance.

String manipulation can lead to performance issues due to object creation overhead and memory usage.

Using StringBuilder always improves performance.

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?