Strings

Strings

University

12 Qs

quiz-placeholder

Similar activities

Chapter 8

Chapter 8

University

10 Qs

Pre Test ComputerProgramming

Pre Test ComputerProgramming

University

10 Qs

GUI Quiz

GUI Quiz

University

10 Qs

Algo 1

Algo 1

University

10 Qs

C++ Switch  and If Else Statements

C++ Switch and If Else Statements

University

15 Qs

Programacion Orientada a Objetos

Programacion Orientada a Objetos

12th Grade - University

10 Qs

Java Quiz 3

Java Quiz 3

University

15 Qs

JAVA - Arrays

JAVA - Arrays

University - Professional Development

15 Qs

Strings

Strings

Assessment

Quiz

Computers

University

Practice Problem

Hard

Created by

sudha reddy

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

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?