






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







































GUIs #
Estimated Grade Ranges
Each question was
graded on a 5-point
scale. The total possible
was 75.
For 2 & 3, Assume you have this class:
Lecture 5, p. 46
{ public class C {public static void main(String[] args)private int b;private static int a; o.b = 12;n.b = 7;m.b = 5;o.a = 5;n.a = 4;m.a = 3;C o = m;C n = new C();C m = new C();
}
(^) what are the values of:
m.a? ___, n.a? ___, o.a? ___, m.b? ___, n.b? ___, o.b? ___
m
n
o
For 2 & 3, Assume you have this class:
Lecture 5, p. 46
{ public class C {public static void main(String[] args)private int b;private static int a; o.b = 12;n.b = 7;m.b = 5;o.a = 5;n.a = 4;m.a = 3;C o = m;C n = new C();C m = new C();
}
(^) C.a
exist? ___ How many of
(^) C.b
m
n
o
Lecture 5, p. 46
{ public class T public static void f(T t) { }private int getA() { return a; }private int a;
}
(^) • Execute
T t2 = new T();
(^) • Call
t.getA();
getA();
this.a
(^) • Print the value of
t.a
of Which of the following things could you do inside the body (^) f()
?
No
(^) this
(^) needed–constructor
NeedExplicit reference present
(^) this
(^) to call method
this
(^) unde
fi ned
Explicit reference
6-7. Pick two of the
(^) fi ve criteria for modularity and name
and brie
fl y describe both.
Lecture 6, p. 3
Protection: It can confine the consequences of failure or prevent them from spreading too far.Continuity: It can adjust smoothly to requirements changes.Understandability: It can be studied on its own, apart from the system it is a part of.Composability: It can be combined with other modules to form new systems. Decomposability: Module can be pulled out of the system and still maintain its integrity.
methods?9. Which object type(s) are allowed to have abstract
Lecture 8, p. 4
Interfaces, Abstract Classes, Concrete Classes
method implementations methods?10. Which object type(s) are allowed to have concrete
Lecture 8, p. 4
Interfaces, Abstract Classes, Concrete Classes
Lecture 8, p. 14
{ public int aspen() { tryInteger a = null; System.out.print("a");return a.intValue();
{ catch (NullPointerException e)} System.out.print("b");
return 0;System.out.print("c");}
b) What value will the function return? a) What will be printed by the function? }
0 bc
Continues normally after Exception thrown, control transferred
(^) try
/ catch
(^) block
interfaces?13. Which of the following things can you do with
Lecture 7, p. 23
(^) • Associate an "aspect" of an object with certain methods.
(^) fi elds.
(^) • De
fi ne a new data type that an object can be tested for using
(^) instanceof
.
(^) • Declare an object reference using the interface as the type of the reference.
(^) new
.
description:15. Match the object-orientation principle with its
Lecture 7, p. 71
Encapsulation
erent method implementations at runtime.
Polymorphism
Inheritance
same time in order to start creating our own screens: We have to introduce several interlocking concepts at theIntroducing Containers/Components/Layout
JComponent
: something that takes up space in a window
JPanel interacts with the mouse or keyboard.)and has a look and feel. (Look: has an appearance. Feel:
: an invisible container that holds components.
JFrame
: a window with normal window controls.
LayoutManager
: an object that arranges components in
JButton a container.
, JLabel
: example components.
Components (2)
JFC components are subclasses of
(^) javax.swing.JComponent
.
Methods ofreason to manually set the location and size of a component.Once we introduce layout managers, there won’t be much
(^) JComponent
(^) include (most-used marked with
(^) ☞
):
Some components are outlined in red.