This section of our 1000+ Java MCQs focuses on String class of Java Programming Language.
a
d
b
b
class string_demo
{
public static void main(String args[])
{
String obj = "I" + "like" + "Java";
System.out.println(obj);
}
}
a) I
b) like
c) Java
d) IlikeJavad
class string_class
{
public static void main(String args[])
{
String obj = “I LIKE JAVA”;
System.out.println(obj.charAt(3));
}
}
a) I
b) L
c) K
a
class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.length());
}
}
a) 9
b) 10
c) 11
d) 12c
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = obj;
obj2 = " world";
System.out.println(obj + " " + obj2);
}
}
a) hello hello
b) world world
c) hello world
d) world helloc
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
}
}
a) false false
b) true true
c) true false
d) false trued
1. String class belongs to \_\_\_\_\_\_\_\_\_\_ package A java.awt
B java.lang
C java.applet
D java.string
b
. Which of the following methods of the “StringBuffer” class is used to find the length of a String? A length()
B Length()
C Capacity()
D capacity()
a