MCQOPTIONS
Saved Bookmarks
This section includes 20 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
The string class deals with string of only character type. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 2. |
Function replace() accepts _____________ arguments. |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | 4 |
| Answer» C. 3 | |
| 3. |
String trim() function is used to _______________________ |
| A. | Remove all the white spaces from the string |
| B. | Remove white space from start of string |
| C. | Remove white space at end of string |
| D. | Remove white space from both the ends of string |
| Answer» E. | |
| 4. |
String class provides function toUpper() to _____________________ |
| A. | Convert first character to uppercase |
| B. | Convert last character to uppercase |
| C. | Convert the whole string characters to uppercase |
| D. | Convert uppercase to lower and lower to uppercases |
| Answer» D. Convert uppercase to lower and lower to uppercases | |
| 5. |
The compareTo() function is used to ________________ |
| A. | Compare strings value to string object |
| B. | Compare string value to string value |
| C. | Compare string object to another string object |
| D. | Compare string object to another string value |
| Answer» D. Compare string object to another string value | |
| 6. |
Function equals() is _______________ and equalIgnoreCase() is _________________ |
| A. | Case Insensitive, case insensitive |
| B. | Case sensitive, Case insensitive |
| C. | Case sensitive, case sensitive |
| D. | Case insensitive, case sensitive |
| Answer» C. Case sensitive, case sensitive | |
| 7. |
The function lastIndexOf() is used to ___________________ |
| A. | Get the index of last occurrence of specified character in argument |
| B. | Get the index of first occurrence of specified character in argument |
| C. | Get the index of last occurrence of first character in string |
| D. | Get the index of last occurrence of last character of string |
| Answer» B. Get the index of first occurrence of specified character in argument | |
| 8. |
String class have a concat() function that is used to _____________________ |
| A. | Replace old string by new string |
| B. | Add two strings |
| C. | Append one string at end of another string |
| D. | Remove a string from end of one string |
| Answer» D. Remove a string from end of one string | |
| 9. |
If two index are given as argument to substring function then ___________________ |
| A. | String of length equal to sum of two arguments is returned |
| B. | String starting from first index and of length equal to send argument |
| C. | String starting from first index and of length equal to sum of two arguments |
| D. | String starting from first index and ending at second index position |
| Answer» E. | |
| 10. |
If only one parameter is passed to substring function then __________________ |
| A. | It returns the character at the specified position |
| B. | It returns the string of length 1 from the specified index |
| C. | It returns the string from specified index till the end |
| D. | It returns the string from starting of string till the specified index |
| Answer» D. It returns the string from starting of string till the specified index | |
| 11. |
Which is the function to get the character present at a particular index in the string? |
| A. | char charAt(index); |
| B. | char charIn(StringName); |
| C. | char charAt(StringName); |
| D. | char charIn(index); |
| E. | ;c) char charAt(StringName);d) char charIn(index); |
| Answer» B. char charIn(StringName); | |
| 12. |
What does function length do in String class? |
| A. | Returns length of string including null character |
| B. | Returns length of string excluding null character |
| C. | Returns length of substring |
| D. | Returns size of string in bytes |
| Answer» C. Returns length of substring | |
| 13. |
How to declare an object of class String? |
| A. | String object_Name = value; |
| B. | String object_name = new; |
| C. | String object_name= new value; |
| D. | String object_name= value new; |
| Answer» B. String object_name = new; | |
| 14. |
Which is a true statement for object of String class? |
| A. | Object are immutable |
| B. | Object are mutable |
| C. | Object are created only once |
| D. | Object can’t be created |
| Answer» B. Object are mutable | |
| 15. |
FUNCTION_EQUALS()_IS_________________AND_EQUALIGNORECASE()_IS__________________?$ |
| A. | Case Insensitive, case insensitive |
| B. | Case sensitive, Case insensitive |
| C. | Case sensitive, case sensitive |
| D. | Case insensitive, case sensitive |
| Answer» C. Case sensitive, case sensitive | |
| 16. |
String class provides function toUpper() to _____________________$ |
| A. | Convert first character to uppercase |
| B. | Convert last character to uppercase |
| C. | Convert the whole string characters to uppercase |
| D. | Convert uppercase to lower and lower to uppercases |
| Answer» D. Convert uppercase to lower and lower to uppercases | |
| 17. |
The compareTo() function is used to ________________$ |
| A. | Compare strings value to string object |
| B. | Compare string value to string value |
| C. | Compare string object to another string object |
| D. | Compare string object to another string value |
| Answer» D. Compare string object to another string value | |
| 18. |
If two arguments are passed to the indexOf() function then ___________________ |
| A. | Second argument indicates the occurrence number of specified character from starting |
| B. | Second argument indicates the occurrence number of specified character from end |
| C. | Second argument indicates the index of the character in first argument |
| D. | Second argument indicates the index of the character from the last of the string |
| Answer» B. Second argument indicates the occurrence number of specified character from end | |
| 19. |
The function lastIndexOf() is used to __________________? |
| A. | Get the index of last occurrence of specified character in argument |
| B. | Get the index of first occurrence of specified character in argument |
| C. | Get the index of last occurrence of first character in string |
| D. | Get the index of last occurrence of last character of string |
| Answer» B. Get the index of first occurrence of specified character in argument | |
| 20. |
String in Java is a? |
| A. | class |
| B. | object |
| C. | variable |
| D. | character array |
| Answer» B. object | |