반응형
Backend/java2018. 8. 7. 20:48배열을 변수에 저장해보자 .

char[] c =new char[size]; // size 만큼 char배열을 만든다 . String s = new String(c); // 만든 c배열을 String s변수에 저장시킨다. return s; // s를 반환 컴파일 할때는 return 되는 접근제한자 or 상위 접근제한자와 비교를 통해 false or true 비교한다 . String -- > str.toCharArray() : char배열로 만들수 있다.

자격증/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