728x90
반응형
출력되는 값은 무엇입니까? 0
int[] a = new int[2];
System.out.println(a[0]);
출력되는 값은 무엇입니까? null
Person[] people = new Person[2];
System.out.println(people[0]);
출력되는 값은 무엇입니까? 0
Person person = new Person();
people[0] = person;
person.age = a[0];
a[0] = 26;
System.out.println(person.age);
출력되는 값은 무엇입니까? 27
a[0]++;
people[1] = people[0];
people[1].age = a[0];
a[0] = 28;
System.out.println(people[0].age);
출력되는 값은 무엇입니까? 오류 발생
String s = null;
if (s != null || !s.isEmpty()) {
System.out.println("Answer A");
} else {
System.out.println("Answer B");
}
출력되는 값은 무엇입니까? 3
String[] strings = new String[5];
strings[0] = "Hello";
strings[2] = "";
strings[4] = "Java";
int countA = 0, countB = 0;
for (String str : strings) {
if (str != null && !str.isEmpty()) {
countA++;
} else {
countB++;
}
}
System.out.println(countB);
728x90
반응형
'TIL > Java' 카테고리의 다른 글
[Java] 예외(Exception) - 코드 안전하게 만들기(try-catch 예외 처리) (0) | 2022.01.07 |
---|---|
[Java] 변수를 안전하게 만드는 법: final (0) | 2022.01.07 |
[Java] null (0) | 2022.01.07 |
[Java] 기본형 vs 참조형 (0) | 2022.01.07 |
[Java] 중간고사: 문제 해결 능력 기르기_코드잇 소개 프로그램 (0) | 2022.01.07 |