-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz1.txt
126 lines (96 loc) · 3.16 KB
/
quiz1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
,Consider the following program:
import myLibrary.*;
public class ShowSomeClass
{
// code for the class...
}
What is the name of the java file containing this program?
,A.myLibrary.java
,B.ShowSomeClass.java
,C.ShowSomeClass
,D.ShowSomeClass.class
,E.Any file name with the java suffix will do
,B
,2
,Which of the following is TRUE?
,A.In java; an instance field declared publicgenerates a compilation error.
,B.int is the name of a class available in the package java.lang
,C.Instance variable names may only contain letters and digits.
,D.A class has always a constructor (possibly automatically supplied by the java compiler).
,E.The more comments in a program; the faster the program runs.
,D
,2
,Consider the following code snippet
String river = new String(“Columbia”);
System.out.println(river.length());
What is printed?
,A.6
,B.7
,C.8
,D.Columbia
,E.river
,C
,1
,A constructor
,A. must have the same name as the class it is declared within.
,B. is used to create objects.
,C. may be declared private
,D. A and B
,E. A B and C
,E
,3
,Which of the following may be part of a class definition?
,A. instance variables
,B. instance methods
,C. constructors
,D. all of the above
,E. none of the above
,D
,3
,What is different between a Java applet and a Java application?
,A. An application can in general be trusted whereas an applet can't
,B. An applet must be executed in a browser environment
,C. An applet is not able to access the files of the computer it runs on
,D. (A) (B) and (C).
,E. None of the above
,D
,5
,Consider
public class MyClass{
public MyClass(){/*code*/}
// more code...
}
To instantiate MyClass; you would write?
,A. MyClass mc = new MyClass();
,B. MyClass mc = MyClass();
,C. MyClass mc = MyClass;
,D. MyClass mc = new MyClass;
,E. It can't be done. The constructor of MyClass should be defined as public void MyClass(){/*code*/}
,A
,2
,What is byte code in the context of Java?
,A. The type of code generated by a Java compiler
,B. The type of code generated by a Java Virtual Machine
,C. It is another name for a Java source file
,D. It is the code written within the instance methods of a class.
,E. It is another name for comments written within a program.
,A
,1
,What is garbage collection in the context of Java?
,A.The operating system periodically deletes all of the java files available on the system.
,B. Any package imported in a program and not used is automatically deleted.
,C. When all references to an object are gone; the memory used by the object is automatically reclaimed.
,D.The JVM checks the output of any Java program and deletes anything that doesn't make sense.
,E. Janitors working for Sun MicroSystems are required to throw away any Microsoft documentation found in the employees' offices.
,C
,4
,You read the following statement in a Java program that compiles and executes.
submarine.dive(depth);
What can you say for sure?
,A. depth must be an int
,B. dive must be a method.
,C. dive must be the name of an instance field.
,D. submarine must be the name of a class
,E. submarine must be a method.
,B
,5