반응형
Backend/java2018. 8. 6. 22:28클래스와 객체의 정의와 용도

클래스와 객체의 정의와 용도 객체 = 속성 + 기능(function) ( 변수 ) + ( 메서드 ) 속성 : 명사 ( Ex : Tv )기능 : 동사 ( Ex : 켜기 , 끄기 , 불륨 높이기 ) 인스턴스의 생성과 사용 1. 인스턴스의 생성방법 ㄱ. 클래스명 참조변수명 ; // 객체를 다루기 위한 참조변수 선언 ㄴ. 참조변수명 = new 클래스명() ; // 객체생성 후 , 생성된 객체 2. 인스턴스의 생성방법2 ㄱ. Tv t1 = new Tv(); ㄴ. Tv t2 = new Tv(); ㄷ. T2 = t1; ㄹ. T1.channel = 7; ㅁ. System.out.println(t1.channel); ㅂ. System.out.println(t2.channel); 3. 인스턴스의 생성방법3 ㄱ. 하나의 인..

자격증/OCJP_ExamD2018. 8. 5. 20:54QUESTION 35

QUESTION 35 Given: 1. import java.util.*; 2. 3. public class LetterASort { 4. public static void main(String[] args) { 5. ArrayList strings = new ArrayList(); 6. strings.add("aAaA"); 7. strings.add("AaA"); 8. strings.add("aAa"); 9. strings.add("AAaa"); 10. Collections.sort(strings); 11. for (String s : strings) { 12. System.out.print(s + " "); 13. } 14. } 15. } What is the result? A. Compilation..

자격증/OCJP_ExamD2018. 8. 5. 20:28QUESTION 34

QUESTION 34 Given: 1. import java.util.*; 2. 3. public class Explorer3 { 4. public static void main(String[] args) { 5. TreeSet s = new TreeSet(); 6. TreeSet subs = new TreeSet(); 7. for (int i = 606; i

자격증/OCJP_ExamD2018. 8. 5. 20:21QUESTION 33

QUESTION 33 Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true? (Choose two.) A. The class implements java.lang.Comparable. B. The class implements java.util.Comparator. C. The interface used to implement sorting allows this class to define only one sort sequence. D. The interface used to implement sorti..

자격증/OCJP_ExamD2018. 8. 5. 20:12QUESTION 32

QUESTION 32 A programmer has an algorithm that requires a java.util.List that provides an efficient implementation of add(0, object), but does NOT need to support quick random access. What supports these requirements? A. java.util.Queue B. java.util.ArrayList C. java.util.LinearList D. java.util.LinkedList Solution : D LinkedList 클래스란??Deque 구현 : Deque 인터페이스는 first와 last로 삽입/삭제하는 것을 모두 지원하기 때문에 ..

자격증/OCJP_ExamD2018. 8. 5. 19:41QUESTION 31

QUESTION 31 Given: public class Key { private long id1; private long id2; // class Key methods } A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key? (Choose two.) A. public int hashCode() B. public boolean equals(Key k) C. public int compareTo(Object o) D. public bo..

반응형
image