gs gs128 Java String Handling - Java Character Extraction - Quiz No.1
gs gs128 Java Quiz
This quiz belongs to book/course code gs gs128 Java of gs organization. We have 136 quizzes available related to the book/course Java. This quiz has a total of 9 multiple choice questions (MCQs) to prepare and belongs to topic Java String Handling. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which of these method of class String is used to extract more than one character at a time a String object?
getchars()
GetChars()
Getchars()
getChars()
Question 2: Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
getBytes()
GetByte()
giveByte()
Give Bytes()
Question 3: In the following Java code, what can directly access and change the value of the variable name?
package test; class Target { public String name = "hello"; }
any class
only the Target class
any class in the test package
any class that extends Target
Question 4: What will be the output of the following Java code?
public class Boxer1 { Integer i; int x; public Boxer1(int y) { x = i+y; System.out.println(x); } public static void main(String[] args) { new Boxer1 (new Integer(4)); } }
The value “4” is printed at the command line
Compilation fails because of an error in line
A NullPointerException occurs at runtime
An IllegalStateException occurs at runtime
Question 5: 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
Question 6: 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
Question 8: 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; } } }
a is a lower case Letter is White space character
b is a lower case Letter is White space character
a is a lower case Letter A is an upper case Letter
a is a lower case Letter 0 is a digit