Strings

Strings

University

12 Qs

quiz-placeholder

Similar activities

OOP - Java Classes

OOP - Java Classes

12th Grade - University

15 Qs

Java Static

Java Static

University

10 Qs

Array

Array

University

11 Qs

Talent Next Java MCQ-1

Talent Next Java MCQ-1

University

10 Qs

Java Operators

Java Operators

University

14 Qs

Third Year Placement Training Revision Test

Third Year Placement Training Revision Test

University

10 Qs

Inheritance

Inheritance

University

10 Qs

MS Core Java Quiz-2 2023

MS Core Java Quiz-2 2023

University

12 Qs

Strings

Strings

Assessment

Quiz

Computers

University

Hard

Created by

sudha reddy

Used 1+ times

FREE Resource

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code?

    class output

    {

        public static void main(String args[])

        {

            char ch;

            ch = "hello".charAt(1);

            System.out.println(ch);

        }

   }

h

e

l

o

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code? 

    class output

    {

        public static void main(String args[])

        {

            char c[]={'a', '1', 'b' ,' ' ,'A' , '0'};

            for (int i = 0; i < 5; ++i)

            {

                   if(Character.isDigit(c[i]))

                       System.out.println(c[i]+" is a digit");

                   if(Character.isWhitespace(c[i]))

                       System.out.println(c[i]+" is a Whitespace character");

                   if(Character.isUpperCase(c[i]))

                       System.out.println(c[i]+" is an Upper case Letter");

                   if(Character.isLowerCase(c[i]))

                       System.out.println(c[i]+" is a lower case Letter");

               i=i+3;

            }

        }

    }

    1.a is a lower case Letter

   2.   is White space character

   1.b is a lower case Letter

    2.  is White space character

1.a is a lower case Letter

    2.A is an upper case Letter

1.a is a lower case Letter

    2.b is a lower case Letter

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code?

class output

    {

        public static void main(String args[])

        {

            String a = "hello i love java";

            System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));

        }

    }

6 4 6 9

5 4 5 9

7 8 8 9

4 3 6 9

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code?

    class output

   {

   public static void main(String args[])

        {

           String c = "Hello i love java";

         int start = 2;

          int end = 9;

           char s[]=new char[end-start];

           c.getChars(start,end,s,0);

           System.out.println(s);

     }

    }

Hello, i love java

i love ja

lo i lo

llo i l

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these methods can be used to convert all characters in a String into a character array?

charAt()

both getChars() & charAt()

both toCharArray() & getChars()

all of the mentioned

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java program? 

    class string_class

    {

        public static void main(String args[])

        {

            String obj = "I LIKE JAVA";  

            System.out.println(obj.length);

        }

  

11

9

12

Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

 Which of the following statements are incorrect?

String is a class

Strings in java are mutable

Every string is an object of class String

Java defines a peer class of String, called StringBuffer, which allows string to be altered

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?