Given: 1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. }); 7. } 8. }
What is the result?
A. test B. null C. An exception is thrown at runtime. D. Compilation fails because of an error in line 1. E. Compilation fails because of an error in line 4. F. Compilation fails because of an error in line 5.
Rei Diaz, 선임 조교 Dan Armendariz, 조교 Eugenia Kim, 조교 Chris Thayer, 편집자 Chris Mehl, 비디오작가
이 코스는 다음의 이해에 관한 모든 것입니다: 당신이 스위치를 켤 때 컴퓨터 안에서 어떤 일이 벌어지는지, 왜 기술지원은 항상 당신의 컴퓨터를 재부팅 시키는지, 당신이 인터넷에서 한 모든 일들이 어떻게 다른 사람들에게 보여지는지, 그리고 어떻게 당신의 컴퓨터가 단지 컴퓨터를 켜는 것만으로도 웜에 감염될 수 있는지에 대한 이해를 할 수 있게 됩니다.
이 코스에서 우리들은 전문 용어와 함께 컴퓨터와 인터넷에 대한 신비함을 사라지게 합니다. 그리고 학생들이 각각 무엇을 할 수 있는지 뿐만 아니라, 모든 용어와 이유 역시 이해할 수 있도록 합니다. 학생들은 이 코스를 마칠 때 새로운 어휘와 좀 더 나은 컴퓨터와 인터넷에 대한 소양을 갖추게 됩니다.
주제는 하드웨어, 소프트웨어, 인터넷, 멀티미디어, 보안, 웹사이트 개발, 프로그램 작성, 그리고 .com을 포함합니다. 이 코스는 컴퓨터 초보자 뿐만 아니라 매일 컴퓨터를 사용하는 사람들 모두를 대상으로 합니다.
(번역 도움 : 배정탁 in JJSSM)
Computer Science E-1: Understanding Computers and the Internet
Harvard Extension School
filmed in Cambridge, Massachusetts September 2006 – January 2007
also available: Computer Science 50: Introduction to Computer Science I Harvard College
Rei Diaz, Head Teaching Fellow Dan Armendariz, Teaching Fellow Eugenia Kim, Teaching Fellow Chris Thayer, Editor Chris Mehl, Videographer
This course is all about understanding: understanding what's going on inside your computer when you flip on the switch, why tech support has you constantly rebooting your computer, how everything you do on the Internet can be watched by others, and how your computer can become infected with a worm just by turning it on. In this course we demystify computers and the Internet, along with their jargon, so that students understand not only what they can do with each but also how it all works and why. Students leave this course armed with a new vocabulary and equipped for further exploration of computers and the Internet. Topics include hardware, software, the Internet, multimedia, security, website development, programming, and dotcoms. This course is designed both for those with little, if any, computer experience and for those who use a computer every day.
Given: 1. public interface A { 2. String DEFAULT_GREETING = “Hello World”; 3. public void method1(); 4. }
A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?
A. public interface B extends A { } B. public interface B implements A { } C. public interface B instanceOf A { } D. public interface B inheritsFrom A { }
[HeadFirst Java - p.258] # 인터페이스 정의 public interface Pet {...} # 인터페이스 구현 public class Dog extends Canine implements Pet {...}
//A를 부모로 하여 B라는 인터페이스를 만들려고 한다. 인터페이스의 정의가 올바른 것은? Answer: A
Given: 1. package sun.scjp; 2. public enum Color { RED, GREEN, BLUE }
1. package sun.beta; 2. // insert code here 3. public class Beta { 4. Color g = GREEN; 5. public static void main( String[] argv) 6. { System.o ut.println( GREEN); } 7. }
The class Beta and the enum Color are in different packages.
Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile? (Choose two.)
A. import sun.scjp.Color.*; B. import static sun.scjp.Color.*; C. import sun.scjp.Color; import static sun.scjp.Color.*; D. import sun.scjp.*; import static sun.scjp.Color.*; E. import sun.scjp.Color; import static sun.scjp.Color.GREEN;
[HeadFirst Java - p.261] # 패키지가 원래 이름 충돌을 방지하기 위한 용도로 만들어진 것은 아니지만, 이름 충돌을 방지하는 것도 패키지의 핵심적인 기능 가운데 하나라고 할 수 있습니다. # 클래스를 package에 집어넣는 방법 1. 패키지 명을 결정합니다. - "com.headfirstjava"를 예로 들면, 클래스 명이 'PackageExercise'라면 - 전체이름은 "com.headfirstjava.PackageExercise" 2. 클래스에 package 선언문을 집어넣습니다. - 소스코드 파일의 첫번째 선언문이어야 한다. - 소스 파일 하나에 들어있는 클래스는 모두 같은 패키지에 들어있어야 한다. - package 선언문이 하나밖에 들어갈 수 없기 때문이다. 3.디렉토리 구조를 패키지 구조에 맞게 설정 - PackageExercise의 소스코드는 - com이라는 디렉토리 밑에 있는 headfirstjava라는 디렉토리 밑에 위치
[HeadFirst Java - p.261] # 정적 임포트를 사용한 코드 import static java.lang.System.out; import static java.lang.Math.*; class WithStatic { public static void main(String [] args) { out.println("sqrt " + sqrt(2.0)); out.println("tan " + tan(60)); } }