Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do we have get(Object o) method in HashSet.
(a) True
(b) False
The question was posed to me by my school teacher while I was bunking the class.
Query is from Data Structures-Set in portion java.util – The Collections Framework of Java
Correct choice is (b) FalseTo explain: get(Object o) method is useful when we want to compare objects based on the comparison of values. HashSet does not provide any way to compare objects. It just guarantees unique objects stored in the collection.
Correct choice is (b) False
To explain: get(Object o) method is useful when we want to compare objects based on the comparison of values. HashSet does not provide any way to compare objects. It just guarantees unique objects stored in the collection.
See lessString in Java is a?
(a) class
(b) object
(c) variable
(d) character array
Correct answer is (a) classThe explanation: None.
Correct answer is (a) class
The explanation: None.
See lessWhich of the below is true about java class structure?
(a) The class name should start with lowercase
(b) The class should have thousands of lines of code
(c) The class should only contain those attribute and functionality which it should; hence keeping it short
(d) The class attributes and methods should be public
Right option is (c) The class should only contain those attribute and functionality which it should; hence keeping it shortFor explanation I would say: Class name should always start with upper case and contain those attribute and functionality which it should (Single Responsibility Principle); henRead more
Right option is (c) The class should only contain those attribute and functionality which it should; hence keeping it short
For explanation I would say: Class name should always start with upper case and contain those attribute and functionality which it should (Single Responsibility Principle); hence keeping it short. The attributes should be usually private with get and set methods.
See lessWhich of these access specifiers must be used for main() method?
(a) private
(b) public
(c) protected
(d) none of the mentioned
The correct choice is (b) publicEasiest explanation: main() method must be specified public as it called by Java run time system, outside of the program. If no access specifier is used then by default member is public within its own package & cannot be accessed by Java run time system.
The correct choice is (b) public
Easiest explanation: main() method must be specified public as it called by Java run time system, outside of the program. If no access specifier is used then by default member is public within its own package & cannot be accessed by Java run time system.
See lessWhat happens if IP Address of host cannot be determined?
(a) The system exit with no message
(b) UnknownHostException is thrown
(c) IOException is thrown
(d) Temporary IP Address is assigned
Right choice is (b) UnknownHostException is thrownThe explanation: UnknownHostException is thrown when IP Address of host cannot be determined. It is an extension of IOException.
Right choice is (b) UnknownHostException is thrown
The explanation: UnknownHostException is thrown when IP Address of host cannot be determined. It is an extension of IOException.
See lessPriorityQueue is thread safe.
(a) True
(b) False
The question was asked during an interview.
My question is from Data Structures-Queue in portion java.util – The Collections Framework of Java
Correct choice is (a) TrueThe best explanation: PriorityQueue is not synchronized. BlockingPriorityQueue is the thread safe implementation.
Correct choice is (a) True
The best explanation: PriorityQueue is not synchronized. BlockingPriorityQueue is the thread safe implementation.
See lessWhat is the difference between length() and size() of ArrayList?
(a) length() and size() return the same value
(b) length() is not defined in ArrayList
(c) size() is not defined in ArrayList
(d) length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list
Correct answer is (d) length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the listExplanation: length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list which is always less than or equal to capaciRead more
Correct answer is (d) length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list
Explanation: length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list which is always less than or equal to capacity.
See lessWhat happens if ServerSocket is not able to listen on the specified port?
(a) The system exits gracefully with appropriate message
(b) The system will wait till port is free
(c) IOException is thrown when opening the socket
(d) PortOccupiedException is thrown
The correct answer is (c) IOException is thrown when opening the socketThe best I can explain: public ServerSocket() creates an unbound server socket. It throws IOException if specified port is busy when opening the socket.
The correct answer is (c) IOException is thrown when opening the socket
The best I can explain: public ServerSocket() creates an unbound server socket. It throws IOException if specified port is busy when opening the socket.
See lessWhich of these is a method of ListIterator used to obtain index of previous element?
(a) previous()
(b) previousIndex()
(c) back()
(d) goBack()
The correct choice is (b) previousIndex()For explanation I would say: previousIndex() returns index of previous element. if there is no previous element then -1 is returned.
The correct choice is (b) previousIndex()
For explanation I would say: previousIndex() returns index of previous element. if there is no previous element then -1 is returned.
See lessWhat does Collections.emptySet() return?
(a) Immutable Set
(b) Mutable Set
(c) The type of Set depends on the parameter passed to the emptySet() method
(d) Null object
Correct option is (a) Immutable SetTo explain I would say: Immutable Set is useful in multithreaded environment. One does not need to declare generic type collection. It is inferred by the context of method call.
Correct option is (a) Immutable Set
To explain I would say: Immutable Set is useful in multithreaded environment. One does not need to declare generic type collection. It is inferred by the context of method call.
See less