Questions
Which of the following symbols is used for representing the XOR operator in Java?
- ~
- &
- |
- ^
How many string objects are created by the given statement?
String str=new String(“Aliens”);
- 0
- 1
- 2
- 4
What will be the value of “str” after executing the following statements?
StringBuffer str=new StringBuffer(“I am a student”);
str.delete(2,6);
- I student
- Istudent
- Itudent
- I am a student
Which of the following statements is/are correct?
A. The size of a vector can grow or shrink.
B. The size of an array can grow or shrink.
- Only A
- Only B
- Both A and B
- Neither A nor B
What is the size and capacity of the Vector Num in the following code?
Vector Num=new Vector(10)
- Size = 10, capacity = 0
- Size = 0, capacity = 10
- Size = 10, capacity = 10
- Size = 0, capacity = 0
The method readLine() can be accessed by the object of a ____________ class to read a string from console.
- InputStreamReader
- InputStream
- BufferedReader
- StringReader
What is the correct syntax of replace() method of the StringBuffer class?
- StringBuffer replace(int s,int e)
- StringBuffer replace(int s,String str)
- StringBuffer replace(int s,String str1,String str2)
- StringBuffer replace(int s,int e,String str)
The methods of NumberFormat class are used to display the numbers in standard formats(Currency values and percentage values).The NumberFormat class belongs to which of the following packages?
- java.lang
- java.io
- java.text
- java.txt
Which of the following statement(s) is/are correct?
A. valueOf() is a static method.
B. toString() is overridden in Integer and Double Class.
- Only A
- Only B
- Both A and B
- Neither A nor B
The constructor StringBuffer() of a StringBuffer class creates a string buffer with the capacity of ________ characters by default.
- 8
- 16
- 32
- 64
The class String is defined in the package ___________.
- java.awt
- java.lang
- java.math
- java.net
Java does not support ____________.
- arrays
- multithreading
- pointers
- constructors
Which of the following methods of a String class is used to compare the given string “str1” to another string “str2” by ignoring the case consideration?
- str1.equals(str2);
- str1.equalsIgnoreCase(str2)
- str1.equalignoreCase(str2)
- str1.equalsIgnorecase(str2)
Which of the following methods is used to get the index within the given string “str” at the first occurrence of the specified substring “str1”?
- str1.indexOf(int ch,int from Index)
- str1.indexOf(String str)
- str.indexOf(string str1)
- str.indexOf(String str1)
Which of the following is not a valid statement in Java?
- str1.equalsIgnoreCase(str2)
- str1.equalsIgnoreCase()
- “Hello”.equalsIgnoreCase(“hello”)
- str1.equals(str2)