1. 다음 Java 코드에서 알맞는 출력 값을 작성하시오.
class Connection { private static Connection _inst = null; private int count = 0; static public Connection get() { if(_inst == null) { _inst = new Connection(); return _inst; } return _inst; } public void count() { count++; } public int getCount() { return count; } } public class main { public static void main(String[] args) { Connection conn1 = Connection.get(); conn1.count(); Connection conn2 = Connection.get(); conn2.count(); Connection conn3 = Connection.get(); conn3.count(); conn1.count(); System.out.print(conn1.getCount()); } }
정답 확인 | 맞췄어요 O | 틀렸어요 X |