tech beamers
  • Viral Tips 🔥
  • Free CoursesTop
  • TutorialsNew
    • Python Tutorial
    • Python Examples
    • C Programming
    • Java Programming
    • MySQL Tutorial
    • Selenium Tutorial
    • Selenium Python
    • Playwright Python
    • Software Testing
    • Agile Concepts
    • Linux Concepts
    • HowTo Guides
    • Android Topics
    • AngularJS Guides
    • Learn Automation
    • Technology Guides
    • Python
    • C
    • Java
    • MySQL
    • Linux
    • Web
    • Android
    • AngularJS
    • Playwright
    • Selenium
    • Agile
    • Testing
    • Automation
    • Best IDEs
    • How-To
    • Technology
    • Gaming
    • Branding
  • Interview & Quiz
    • SQL Interview
    • Testing Interview
    • Python Interview
    • Selenium Interview
    • C Sharp Interview
    • Java Interview
    • Web Development
    • PHP Interview
    • Python Quizzes
    • Java Quizzes
    • Selenium Quizzes
    • Testing Quizzes
    • HTML CSS Quiz
    • Shell Script Quizzes
    • Python Interview
    • SQL Query Interview
    • SQL Exercises
    • Selenium Interview
    • Playwright Interview
    • QA Interview
    • Manual Testing
    • Rest API Interview
    • Linux Interview
    • CSharp Interview
    • Python Function Quiz
    • Python String Quiz
    • Python OOP Quiz
    • Python DSA Quiz
    • ISTQB Quiz
    • Selenium Quiz
    • Java Spring Quiz
    • Java Collection Quiz
    • JavaScript Quiz
    • Shell Scripting Quiz
  • ToolsHot
    • Python Online Compiler
    • Python Code Checker
    • C Online Compiler
    • Review Best IDEs
    • Random Letter Gen
    • Random Num Gen
    • Online Python Compiler
    • Python Code Checker
    • Python Code Quality
    • Username Generator
    • Insta Password Generator
    • Google Password Generator
    • Free PDF Merger
    • QR Code Generator
    • Net Worth Calculator
tech beamers
Search
  • Viral Tips 🔥
  • Free CoursesTop
  • TutorialsNew
    • Python Tutorial
    • Python Examples
    • C Programming
    • Java Programming
    • MySQL Tutorial
    • Selenium Tutorial
    • Selenium Python
    • Playwright Python
    • Software Testing
    • Agile Concepts
    • Linux Concepts
    • HowTo Guides
    • Android Topics
    • AngularJS Guides
    • Learn Automation
    • Technology Guides
  • Interview & Quiz
    • SQL Interview
    • Testing Interview
    • Python Interview
    • Selenium Interview
    • C Sharp Interview
    • Java Interview
    • Web Development
    • PHP Interview
    • Python Quizzes
    • Java Quizzes
    • Selenium Quizzes
    • Testing Quizzes
    • HTML CSS Quiz
    • Shell Script Quizzes
  • ToolsHot
    • Python Online Compiler
    • Python Code Checker
    • C Online Compiler
    • Review Best IDEs
    • Random Letter Gen
    • Random Num Gen
Follow US
© TechBeamers. All Rights Reserved.
Java QuizJava Tutorials

Core Java Quiz on Strings – Make Sure You Know the Essentials

Last updated: Mar 07, 2025 7:54 am
Meenakshi Agarwal
By
Meenakshi Agarwal
Meenakshi Agarwal Avatar
ByMeenakshi Agarwal
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large...
Follow:
No Comments
5 months ago
Share
14 Min Read
SHARE

Hello! Friends, we have prepared a 40-question core Java quiz online test for you. It intends to quiz you on the concept of Java Strings and how you use them in your programs.

Java String is one of the commonly asked topics in all Java interviews, so this quiz is here to test your preparation level. With 40 questions on Strings, it’ll prove to be a great help for those interested in learning the concept of Java String.

This test covers questions on several Java classes, such as String, StringBuffer, and StringBuilder, that implement string-handling functionality. It will help Java developers, and the QA engineers can also attempt it and check their readiness to start developing any automation project using Java.

However, beginners should also check out this entry-level test for Java developers. Another Java concept that you should be familiar with is the Collection framework. Since it’s an important topic, read these essential questions on the Collection framework and fill in the gaps you may have.

Core Java Quiz Online Test – Make Sure You Know Strings

Answer Key with Reasoning

Here’s a reasoning table explaining the correct answers for each question:

Q#QuestionCorrect AnswerReasoning
1Which is invalid for Java String?String represents an array.Java Strings are not arrays, they are objects.
2Why is String immutable?All of these.String immutability helps with caching, security, and performance.
3Difference between String & StringBuffer?String is immutable.String objects cannot be changed, whereas StringBuffer allows modifications.
4Difference between C and Java String?C Strings are null-terminated.C uses \0 to terminate strings, Java does not.
5What does replaceAll() do?Replaces all matches.replaceAll() replaces all occurrences of a substring.
6Which method compares Strings?compareTo(String str)compareTo() compares lexicographically, while equals() checks exact matches.
7Convert String to byte array?getBytes() and new String(byte[])getBytes() converts String to bytes, new String(byte[]) converts it back.
8What is the Java String pool?Stores String literals in heap.JVM stores String literals in a special memory area to save space.
9Purpose of intern()?Moves String to pool.intern() ensures a single instance of the String exists in the pool.
10Why use char[] for passwords?String stays in memory.String values cannot be erased from memory, but char[] can.
11What is output of equals()?false, trueequals() compares values, while == checks references.
12Difference between ‘==’ and equals()?References vs values.== checks if objects are same reference, equals() checks actual content.
13Are immutable objects thread-safe?trueImmutability ensures no shared modification issues in threads.
14Does modifying a String create a new object?trueJava String objects are immutable, so changes result in new objects.
15Use StringBuffer for modifications?trueStringBuffer is mutable and optimized for modifications.
16Can Strings be used in switch?Yes, from JDK 7.Java 7 introduced String-based switch statements.
17What does split(‘\s+’) do?Splits whitespace.\\s+ is a regex pattern that splits by one or more spaces.
18Output of parseInt(“10”)?10parseInt("10") converts the String “10” to integer 10.
19Default StringBuilder capacity?16StringBuilder starts with a 16-character buffer.
20Output of substring(9, 12)?“bee”, 3Extracts characters from index 9 to 11.
21What is “Java”.length()?4"Java" has 4 characters.
22What is “Java”.charAt(2)?“v”The third character (index 2) is ‘v’.
23Which returns ‘?’?JavaStr.charAt(21)The 22nd character (index 21) is ‘?’.
24Correct way to concatenate Strings?Str1.concat(Str2)concat() efficiently joins Strings.
25What does toString() return?String representation.toString() returns a String representation of an object.
26Is String a keyword?falseString is a class, not a keyword.
27Which class is final?StringString is final, so it cannot be subclassed.
28StringBuffer vs StringBuilder?StringBuffer is thread-safe.StringBuffer has synchronized methods, making it thread-safe.
29Where are String objects stored?HeapAll String objects are stored in Heap Memory.
30What is the output?trueBased on the question context.
31Output of the loop?AcThe correct loop behavior produces "Ac".
32Convert char[] to String?abcConverting a char[] { ‘a’, ‘b’, ‘c’ } results in "abc".
33Convert ASCII to String?BCDThe ASCII values convert to "BCD".
34What does toString() return?String representation.toString() converts objects to Strings.
35Output of string comparison?trueThe comparison is true based on the logic.
36What happens when modifying String?New object is created.Strings are immutable, so modifications create new objects.
37Default value of an uninitialized String?null.Uninitialized String variables default to null.
38Can String be used in for-each loop?Yes, for characters.Strings are iterable by character in for-each loops.
39Which class is mutable?Both 2 and 3.StringBuffer and StringBuilder are mutable.
40substring(2, 5) for “JavaString”?“vaS”Extracts characters from index 2 to 4.

Key Takeaways from Core Java Quiz

The demand for Java is growing but also the competition among the developers. IT companies are using new avenues to hunt for the best talent like online evaluation platforms. Hence, you should also be on your toes and keep working on your skills. We’ll be helping you out with more challenging stuff like this core Java online test. 

Hopefully, this quiz helped us improve your Java programming skills. Rest assured that we’ll continue to create new quizzes on trending subjects and update the older ones as well.

Worth Reading: Java Convert String to int

Please lend us your support by sharing this post with your friends and on the social media platforms.

Let’s now end the quiz with a famous quote from Niklaus Wirth who has been a prominent Swiss computer scientist.

Programming is usually taught by examples.

Best,
TechBeamers

Related

TAGGED:programming
Share This Article
Whatsapp Whatsapp LinkedIn Reddit Copy Link
Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

List of Topics

Stay Connected

FacebookLike
XFollow
YoutubeSubscribe
LinkedInFollow

Subscribe to Blog via Email

Enter your email address to subscribe to latest knowledge sharing updates.

Join 994 other subscribers

Continue Reading

  • Java Programming Practice Test for FreshersJan 30
  • Top 20 Java Serialization Interview QuestionsFeb 2
  • Java Exception Quiz with 20 Questions and AnswersFeb 13
  • Java Multithreading QuizFeb 17
  • J2EE Online Test for Freshers – Java ProgrammingMar 16
  • Entry-Level Java Developer QuizSep 26
  • Java Collections Quiz for DevelopersDec 16
  • Java Hibernate Online Practice TestAug 16
  • Java Spring MVC Quiz for Beginners Part-1Jun 1
View all →

RELATED TUTORIALS

Java Switch Case with Examples

Switch-Case in Java

By Meenakshi Agarwal
2 years ago
Java While Loop Tutorial

While Loop in Java

By Meenakshi Agarwal
2 years ago
Java Programming Practice Test.

Java Programming Practice Test for Freshers

By Meenakshi Agarwal
5 months ago
Online Python Quiz for Beginners - Python Classes and Objects

Python Quiz: Classes and Objects Part 1

By Meenakshi Agarwal
5 months ago
© TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use