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);
}
}
Strings
Quiz
•
Computers
•
University
•
Hard
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
10 questions
JAVA I/O
Quiz
•
University
15 questions
Soal Java
Quiz
•
11th Grade - University
11 questions
SAINS KOMPUTER 1.3
Quiz
•
University
10 questions
Java Static
Quiz
•
University
10 questions
Inheritance
Quiz
•
University
15 questions
Round 4 - Harvest
Quiz
•
University
9 questions
Java Programming Structures
Quiz
•
University
10 questions
java operators
Quiz
•
University
15 questions
Multiplication Facts
Quiz
•
4th Grade
25 questions
SS Combined Advisory Quiz
Quiz
•
6th - 8th Grade
40 questions
Week 4 Student In Class Practice Set
Quiz
•
9th - 12th Grade
40 questions
SOL: ILE DNA Tech, Gen, Evol 2025
Quiz
•
9th - 12th Grade
20 questions
NC Universities (R2H)
Quiz
•
9th - 12th Grade
15 questions
June Review Quiz
Quiz
•
Professional Development
20 questions
Congruent and Similar Triangles
Quiz
•
8th Grade
25 questions
Triangle Inequalities
Quiz
•
10th - 12th Grade