EXAM2QUESTIONS
EXAM2QUESTIONS
1. assertSame() :
- Assertions API provide static assertSame() method. This
method helps us in validating that expected and actual refer
to the exact same object. JUnit uses == operator to perform
this assert. If the actual and expected value refers to the same
object then the test case will pass.
-
2. Marker Interfaces :
- Serializable: This is perhaps the most well-known marker
interface. A class that implements Serializable indicates that
its instances can be serialized, i.e., converted into a byte
stream and later deserialized back into a copy of the object.
- Cloneable: This marker interface indicates that a class allows
a field-for-field copy of instances to be made using the
clone() method.
- Remote: This marker interface is used in Java RMI (Remote
Method Invocation) to indicate that an object can be used
remotely.
3. Code:
import java.util.*;
import java.util.TreeMap;
}
}
Output :
{brazil=4, china=3, india=1, usa=2}
4. keyword used make class immutable in java
- options : final, constant, static, string class
- Answer: final
5. Which of the following acquire synchronized keyword ?
- Synchronized methods and Synchronized blocks
6. what keyword is used when class don't want handle the exception ?
- Throws Keyword
7. which of the following can store garbage values , String or
StringBuilder ?
- StringBuilder can , But not String .
8. maven command to find artifact location in maven , options : site,
install, delay ?
9. Code:
Interface i
{
void getSomeThing();
void getNothing();
protected void getAnything();
}
- Answer : No, protected abstract methods cannot be
declared in Java interfaces.
10. StringBuffer is Thread safe .
11. Which of the following is not correct about JUint ?
Answer: Junit cannot be Automated .
12. Access for subclass in any package and classes in same package
- Protected
13. A company has a business application that provides ……
Which two Design concepts most likely explain the situation ?
- Answer: Low cohesion and Tight Coupling .
14. Which of the following is not part of the maven process ?
- Answer : Integration
15. One class derived from two base classes ?
- Answer: Multiple Inheritence
16. What will happen if two thread of same priority are called to be
processed simultaneously ?
- Answer: It depends on the operating System.
17. Which of the following correct related to ArrayList and Vector ?
- Answer: Vector is Thread safe .
18. Which of the following method of access class checks two
primitive/Objects of the content ?
- Answer: assertEquals().
19. 1-String s = new String(); s=s.replace(‘e’,3);
2-StringBuilder rb = new replacable();
rb = null;
- Answer: Statement 2 only .
20. When t1,t2,t3 are running simultaneously , then t2.join() , order of
execution is ?
- Answer : first t2 is executed and t1 and t3 will be followed
.
21. Thread p = Thread.currentThread();
System.out.println(p.IsAlive());
- Answer : True.
22. Treeset Question on iterator .
- Answer : Four, one, three , two
23. User defined Exception is :
- Answer : Checked Exception .
24. Which of following is true about the constructor ?
- Answer: Constructor can be Overloaded.
25. Which of the following is correct syntax to override below Method
?
Public void myMethod(String a, String b);
- Answer: Public void myMethod(String a, String b);