R4RIN
Articles
Java 8
MCQS
Java MCQ Quiz Hub
Java Mcq Question Set 9
Choose a topic to test your knowledge and improve your Java skills
1. Which of these is wrapper for simple data type float?
Double
double
float
Float
2. Which of the following is method of wrapper Float for converting the value of an object into byte?
byte bytevalue()
Bytevalue()
Byte Bytevalue()
bytevalue()
3. Which of these methods is used to check for infinitely large and small values?
Isinfinite()
isInfinite()
IsNaN()
isNaN()
4. Which of the following package stores all the simple data types in java?
java.packages
util
lang
java
5. Which of these is a wrapper for data type int?
Byte
Long
Both a & b
Integer
6. Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?
Integer hashcode()
int hashCode()
int hashcode()
int hash()
7. Which of these is a super class of wrappers Long, Character & Integer?
Number
Long
Float
Digits
8. Which of these is wrapper for simple data type char?
Character
Float
String
Both a & c
9. Which of the following is method of wrapper Integer for converting the value of an object into byte?
bytevalue()
Byte Bytevalue()
Bytevalue()
byte bytevalue()
10. Which of these methods is used to obtain value of invoking object as a long?
Long longvalue()
long longValue()
Long Longvalue()
long value()
11. Which of these class have only one field �TYPE�?
Process
Void
Runtime
System
12. Which of the following method of Process class can terminate a process?
void destroy()
void terminate()
void kill()
void exit()
13. �Standard output variable �out� is defined in which class?
Process
Void
System
Runtime
14. Which of these class can encapsulate an entire executing program?
Process
Runtime
System
Void
15. Which of the following is method of System class is used to find how long a program takes to execute?
currenttimeMillis()
currentTimeMillis()
currenttime()
currentTime()
16. Which of these class holds a collection of static methods and variables?
System
Void
Runtime
Process
17. Which of these keywords is used to define packages in Java?
Pkg
Package
package
pkg
18. Which of these is a mechanism for naming and visibility control of a class and its content?
Object
Interface
Packages
None
19. Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
Protected
No Modifier
Public
All of the above
20. Which of these access specifiers can be used for a class so that it's members can be accessed by a different class in the different package?
Public
Private
Protected
None
21. Which of the following is correct way of importing an entire package pkg?
Import pkg.
Import pkg.*
import pkg.
import pkg.*
22. Which of the following is incorrect statement about packages?
A package can be renamed without renaming the directory in which the classes are stored.
Package defines a namespace in which classes are stored.
Java uses file system directories to store packages.
A package can contain other package within it.
23. Output : package pkg; class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1, x); System.out.println(s1); } }
Hexlo
xxxxx
xello
Hxllo
24. Which of these class is superclass of String and StringBuffer class?
ArrayList
java.lang
java.util
None
25. Which of these operators can be used to concatenate two or more String objects?
+
&
||
+=
26. Which of these method of class String is used to obtain length of String object?
lengthof()
Sizeof()
get()
length()
27. Which of these method of class String is used to extract a single character from a String object?
charat()
charAt()
ChatAt()
CHARAT()
28. Which of these constructors is used to create an empty String object?
String()
String(void)
String(0)
None
29. Which of these is an an correct statement?
StringBuffer class is used to store string in a buffer for later use.
String object can point to some other reference of String variable.
String objects are immutable, they cannot be changed.
None
30. Which of these method of class String is used to compare two String objects for their equality?
Equals()
equals()
Isequal()
isequal()
31. Which of these methods is used to compare a specific region inside a string with another specific region in another string?
regionMatches()
RegionMatches()
regionMatch()
match()
32. Which of these method of class String is used to check weather a given object starts with a particular string literal?
Starts()
ends()
endsWith()
startsWith()
33. What is the value returned by unction compareTo() if the invoking string is less than the string compared?
value less than zero
value greater than zero
zero
None
34. Which of these data type value is returned by equals() method of String class?
boolean
char
int
All of the above
35. What will s2 contain after following lines of code? String s1 = one; String s2 = s1.concat(two)
one
two
twoone
onetwo
36. Which of these method of class String is used to remove leading and trailing whitespaces?
startsWith()
Trim()
trim()
doTrim()
37. What is the value returned by function compareTo() if the invoking string is less than the string compared?
value less than zero
value greater than zero
zero
None
38. Which of the following statement is correct?
replace() method replaces all the characters in invoking string with another character.
replace() replace() method replaces last occurrence of a character in invoking string with another character.
replace() method replaces only first occurances of a character in invoking string with another character.
replace() method replaces all occurrences of one character in invoking string with another character.
39. Which of these class is used to create an object whose character sequence is mutable?
StringBuffer()
String()
Both of the mentioned
None
40. Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
join()
append()
concat()
concatenate()
41. Which of these method of class StringBuffer is used to find the length of current character sequence?
capacity()
Capacity()
Length()
length()
42. What is the string contained in s after following lines of code? StringBuffer s new StringBuffer(Hello); s.deleteCharAt(0);
ello
llo
Hell
Hel
43. Which of the following statement is correct?
reverseall() method reverses all characters.
reverse() method reverses all characters.
replace() method replaces last occurrence of a character in invoking string with another character
replace() method replaces first occurrence of a character in invoking string with another character.
44. Which of these method of class StringBuffer is used to extract a substring from a String object
SubString()
substring()
Substring()
None
45. What will s2 contain after following lines of code? StringBuffer s1 = one; StringBuffer s2 = s1.append(two)
one
two
twoone
onetwo
46. Which of the following are incorrect form of StringBuffer class constructor?
StringBuffer(int size)
StringBuffer()
StringBuffer(int size , String str)
StringBuffer(String str)
47. Which of these class can generate an array which can increase and decrease in size automatically?
DynamicsList()
DynamicList()
ArrayList()
LinkedList()
48. Which of these method can be used to increase the capacity of ArrayList object manually?
ensureCapacity()
increasecapacity()
increaseCapacity()
Capacity()
49. Which of these method of ArrayList class is used to obtain present size of an object?
index()
size()
capacity()
length()
50. Which of these methods can be used to obtain a static array from an ArrayList object?
Array()
toArray()
covertArray()
covertoArray()
Submit