Site icon DataFlair

Quiz on Java String

quiz on java string

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Absolutely! Are you ready to put your Java string skills to the ultimate test? Buckle up and prepare to embark on a thrilling adventure with this interactive quiz! Packed with challenging questions, it’s designed to fully assess your grasp of string manipulation, methods, and those core concepts that make you a string master. No matter if you’re a seasoned Java developer or just beginning your coding journey, this quiz is a guaranteed blast.

It’s the perfect way to solidify your existing knowledge, pinpoint areas where you can shine even brighter, and ultimately unlock your true string mastery! So, are you ready to dive in and conquer this string challenge? Let’s test your knowledge of Java String.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question
    1. class Sample {

    public static void main ( String args [ ] )

    {

    String text = “DataFlair”;

    system.out.println(text.length());

    }

    }

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class Example {

    public static void main ( String args [ ] )

    {

    String s = new String();

    system.out.println(s);

    }

    }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    class StringExample {

    public static void main ( String args [ ] ) 

    Char data[] = { “h” , “e” , “l” , “o” , “o” };

    String s = new String(data);

    system.out.println(s);

    }

    }

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    class StringProgram {

    public static void main ( String args [ ] )

    {

    String one = “Data”;

    Char a = { ‘F’ , ‘l’ , ‘a’, ‘i’, ‘r’ };

    String two = new String(a);

    system.out.println(one.concat(two));

    }

    }

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    Which of the following is not a way to declare a string in Java ?

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

     class CompareExample {

    public static void main ( String args [ ] )

    {

    String First = “Data”;

    String Second = “Flair”;

    if(First.isequals(Second) {

    system.out.println(“These two strings are equal”);

    } else {

    system.out.println(“These two strings are not equal”);

    }

    }

    }

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

     class SplitExample {

    public static void main ( String args [ ]  )

    {

    String datas = “DataFlair , ”webservices”;

    String data[] = datas.split(“,”);

    system.out.println(Arrays.toString(data));

    }

    }

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    Which of the following is the correct syntax to compare two strings ?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class TrimExample {

    public static void main ( String args [ ] ) 

    {

    String text = “Hello World !”;

    String originalvalue = text.trim();

    system.out.println(originalvalue.length());

    }

    }

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

     class UpperCase {

    public static void main( String args [ ] )

    {

    String data = “dataflair”;

    String a = data.charAt(0).toUpperCase();

    String b = data.charAt(1);

    String c = data.charA(2);

    String d = data.charAt(3);

    String e = data.charAt(4).toUppercase();

    String f = data.charAt(5);

    String g = data.charAt(6);

    String h = data.charAt(7);

    String i = data.charAt(8);

     

    system.out.println(a+b+c+d+e+f+g+h+i);

    }

    }

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

    class Index {

    public static void main ( String args [ ] ) 

    {

     

    String s = “World”;

    int a = s.indexof(‘r’);

    system.out.println(a);

    }

    }

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    class GetBytes {

    public static void main ( String args [ ] ) 

    {

    String text = “ABCD”;

    int a = text.charAt(3).getBytes();

    system.out.println(a);

    }

    }

    class GetBytes {

    public static void main ( String args [ ] ) 

    {

    String text = “ABCD”;

    int a = text.charAt(3).getBytes();

    system.out.println(a);

    }

    }

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    Which of the following methods in Java is used to return a formatted output?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    class AddingString {

    public static void main (String args [ ] )

    {

    String a = “9”;

    String b = “9”;

    String c = a + b ;

    system.out.println(c);

    }

    }

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    Why toChararray() method used in Java?

    Correct
    Incorrect

Summary:

Conquering those challenges on the Java strings quiz is a fantastic first step! Now that you’ve aced that hurdle, it’s all about keeping the momentum going to truly master this essential Java building block. Remember, just like building muscles, strengthening your Java skills takes dedication and consistent practice.

To really dive deep and solidify your understanding, explore the treasure trove of Java tutorials and courses we offer. These resources will provide in-depth knowledge, taking you beyond the basics and unlocking the full potential of Java strings.

But the learning doesn’t stop there! We’ll keep the fun and challenge rolling with even more interactive quizzes designed to push your boundaries and solidify your programming skills. So buckle up and get ready for an amazing Java strings adventure!

Exit mobile version