Questions
In System.out.println(), the keyword out is the _________.
- class
- object
- method
- vriable
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
Which of the following methods is used to convert a given string to a new character array?
- toArray()
- StringToArray()
- toCharArray()
- toCArray()
Which of the following methods is used to check whether the stream is ready to read or not?
- start()
- ready()
- isready()
- isstart()
What would be the value of i after the execution of the following statements in Java?
int i;
String st1=”Rakesh”;
String st2=”Roshan”;
i=st1.compareTo(st2);
- 0
- 1
- -1
- +1
Which of the following is the correct way to read a character?
-
||
|---|
| char ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.out));
ch=(char)br.read();| -
||
|---|
| char ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ch=br.read();| -
||
|---|
| char ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ch=(char)br.read();| -
||
|---|
| char ch;
BufferedReader br=new BufferedReader(System.in);
ch=(char)br.read();|
What would be the value of i and ch after the execution of the following statements in Java?
int i;
char ch;
String st1=”Rakesh Roshan”;
i=st1.indexOf(‘e’);
ch=st1.charAt(5);
- The value of i will be 4 and the value of ch will be ’s’.
- The value of i will be 3 and the value of ch will be ’h’.
- The value of i will be 3 and the value of ch will be ’s’.
- The value of i will be 4 and the value of ch will be ’h’.
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
How many parameterized constructors are defined for a Scanner class?
- 5
- 6
- 7
- 8
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)
Which of the following is the correct printf() statement in Java?
- printf(“Hello”);
- Printf“Hello”;
- System.out.printf(“Hello”);
- None of the above
Objects of ___________ class are useful in breaking down the inputs from the user into tokens.
- InputStreamReader
- BufferedReader
- Scanner
- Tokens
Which of the following is the method of a StringTokenizer class?
- Token()
- nextToken()
- println()
- ttype()
Which of the following is not directly derived from the Reader class?
- BufferedReader
- InputStreamReader
- FilterReader
- PushBackReader
Character Oriented Input Stream provides support for reading and writing _____ characters.
- 1-bit
- 8-bit
- 16-bit
- 32-bit
The LineNumberInputStream, DataInputStream, BufferedInputStream, and PushBackInputStream classes are derived from ___________________ class.
- FileInputStream
- PipedInputStream
- FilterInputStream
- ByteArrayInputStream
In Java, the inputs are always considered as ________ datatypes.
- integer
- character
- byte
- string
Which of the following methods is used to calculate the number of times the tokenizer's nextToken method can be called before it generates an exception?
- numberOfTokens()
- countTokens()
- numberOfElement()
- tokens()