Instruction
- Total number of questions : 10.
- Time alloted : 10 minutes.
- Each question carry 1 mark.
- No Negative marks
- DO NOT refresh the page.
- All the best :-).
1. |
Which of these is an incorrect statement? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: StringBuffer class is used to create strings that can be modified after they are created. |
2. |
What is the output of this program? 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); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: getChars(start,end,s,0) returns an array from the string c, starting index of array is pointed by start and ending index is pointed by end. s is the target character array where the new string of letters is going to be stored and the new string will be stored from 0th position in s. |
3. |
What is the output of this program? class output { public static void main(String args[]) { String c = " Hello World "; String s = c.trim(); System.out.println("\""+s+"\""); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: trim() method is used to remove leading and trailing whitespaces in a string. |
4. |
What is the output of this program? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v')); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: indexof(‘c’) and lastIndexof(‘c’) are pre defined function which are used to get the index of first and last occurrence of the character pointed by c in the given array. |
5. |
What is the output of this program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); System.out.println(c.length()); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: length() method is used to obtain length of StringBuffer object, length of “Hello” is 5. |
6. |
What is the output of this program? class output { public static void main(String args[]) { String c = "Hello i love java"; boolean var; var = c.startsWith("hello"); System.out.println(var); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: startsWith() method is case sensitive “hello” and “Hello” are treated differently, hence false is stored in var. |
7. |
Which of the following is incorrect statement about packages? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: A package can be renamed only after renaming the directory in which the classes are stored. |
8. |
Which of the following is incorrect statement about packages? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: All methods and variables are implicitly public if interface is declared public. |
9. |
Which of these methods is used to check for infinitely large and small values? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: isinfinite() method returns true is the value being tested is infinitely large or small in magnitude. |
10. |
Which of these methods is used to obtain value of invoking object as a long? |
|||||||||||||||||||
|