Search Header Logo

String Equality and Case Conversion

Authored by Mrs JYOTHSNA REDDY

Information Technology (IT)

12th Grade

Used 1+ times

String Equality and Case Conversion
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

55 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which method checks two Java strings for content equality rather than reference equality?

compare() compares generic objects

compareTo() orders lexicographically

equals() compares string contents

== operator compares object references

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Given: String s1 = "Hello"; String s2 = s1.toUpperCase(); What is printed by System.out.println(s1 == s2)?

true because both have same letters

false because toUpperCase creates new object

true because String literals are interned

false because equals compares references

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What does str.equalsIgnoreCase("test") evaluate when str holds any casing of "TeSt"?

Checks whether strings are interned

Compares strings including case sensitivity

Converts str to lowercase permanently

Compares strings ignoring case differences

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Given: String s1 = "abc"; String s2 = "ABC"; System.out.println(s1.equalsIgnoreCase(s2)); What is printed?

true

false

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Given: String s = "Java"; System.out.println(s.toLowerCase().equals("java")); What is the output?

false

true

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Given: String s = "abc"; System.out.println(s.compareTo("abd")); Which best describes the printed value?

A compilation error

The exact value zero

A negative number

A positive number

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Given: String s1 = "Hello"; String s2 = s1; What does System.out.println(s1 == s2) print?

true

false

null

throws error

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?