반응형
자격증/OCJP_ExamA2018. 7. 8. 02:53QUESTION 41

QUESTION 41 Given a pre-generics implementation of a method: 11. public static int sum(List list) { 12. int sum = 0; 13. for ( Iterator iter = list.iterator(); iter.hasNext(); ) { 14. int i = ((Integer)iter.next()).intValue(); 15. sum += i; 16. } 17. return sum; 18. } What three changes allow the class to be used with generics and avoid an unchecked warning? (Choose three.) A. Remove line 14. B...

자격증/OCJP_ExamA2018. 7. 8. 02:44QUESTION 40

QUESTION 40 Which two statements are true about the hashCode method? (Choose two.) A. The hashCode method for a given class can be used to test for object equality and object inequality for that class. B. The hashCode method is used by the java.util.SortedSet collection class to order the elements within that set. C. The hashCode method for a given class can be used to test for object inequality..

자격증/OCJP_ExamA2018. 7. 8. 02:32QUESTION 39

QUESTION 39 Given: 1. public class Person { 2. private String name; 3. public Person(String name) { this.name = name; } 4. public boolean equals(Person p) { 5. return p.name.equals(this.name); 6. } 7. } Which statement is true? A. The equals method does NOT properly override the Object.equals method. B. Compilation fails because the private attribute p.name cannot be accessed in line 5. C. To wo..

자격증/OCJP_ExamA2018. 7. 8. 02:18QUESTION 38

QUESTION 38 Given: 1. public class Boxer1{ 2. Integer i; 3. int x; 4. public Boxer1(int y) { 5. x = i+y; 6. System.out.println(x); 7. } 8. public static void main(String[] args) { 9. new Boxer1(new Integer(4)); 10. } 11. } What is the result? A. The value 4 is printed at the command line. B. Compilation fails because of an error in line 5. C. Compilation fails because of an error in line 9. D. A..

자격증/OCJP_ExamA2018. 7. 8. 02:03QUESTION 37

QUESTION 37 Given: 01. Float pi = new Float(3.14f); 02. if (pi > 3) { 03. System.out.print("pi is bigger than 3. "); 04. } 05. else { 06. System.out.print("pi is not bigger than 3. "); 07. } 08. finally { 09. System.out.println("Have a nice day."); 10. } What is the result? A. Compilation fails. B. pi is bigger than 3. C. An exception occurs at runtime. D. pi is bigger than 3. Have a nice day. E..

자격증/OCJP_ExamA2018. 7. 8. 01:59QUESTION 36

QUESTION 36 Given: public void method() { A a = new A(); a.method1(); } Which statement is true if a TestException is thrown on line 3 of class B? 1. public class A{ 2. public void method1() { 3. try { 4. B b = new B(); 5. b.method2(); 6. //more code here 7. } catch (TestException te){ 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class B{ 2. public void method2() throws TestExce..

반응형
image