



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Object-Oriented Programming and Design; Subject: COMPUTER SCIENCE; University: University of Arizona; Term: Unknown 1989;
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




ArrayList list = new ArrayList(); list.add("a"); list.add("b"); list.add("c"); ArrayList list2 = new ArrayList(); list2.add("d"); list2.add(list); list2.add("e"); System.out.println(list2);
String s1; Object o1; Object o2 = new String("abc"); // Compiles ______ Integer anInt = new Object(); // Compiles ______ Integer int2 = (Integer)o1; // Compiles ______ String s2 = o2; // Compiles ______ System.out.println((String)o2); // Compiles ______ System.out.println((Integer)s2); // Compiles ______
ArrayList list = new ArrayList(); list.add(new Integer(3)); list.add(new Integer(5)); list.add(new Integer(1)); list.add(new Integer(4)); Iterator itr = list.iterator(); System.out.println(itr.hasNext()); System.out.println(itr.next()); System.out.println(itr.next()); System.out.println(itr.next());
JTextField inputField = new JTextField("123point4"); double input = 0.0; try { input = Double.parseDouble(inputField.getText()); System.out.println("Good"); } catch (RuntimeException rte) { System.out.println("Bad"); } System.out.println("Ugly");
Abba a = new Abba("Kim"); Bar b = new Bar("Devon"); Goo g = new Goo("Chris"); a.one(); // __________________________________ System.out.println("\n"); a.two(); // __________________________________ System.out.println("\n"); b.one(); // __________________________________ System.out.println("\n"); b.two(); // __________________________________ System.out.println("\n"); b.three();// _________________________________ System.out.println("\n"); g.one(); // __________________________________ System.out.println("\n"); g.two(); // __________________________________ System.out.println("\n"); g.three();// __________________________________ System.out.println("\n"); class Abba extends Object { private String id; public Abba(String ID) { id = ID + " "; } public String getID() { return id; } public void one() { System.out.print("A1 " + getID()); } public void two() { System.out.print("A2 "); three(); } public void three() { System.out.print("A3 " + getID()); } } //////////////////////////////////// class Bar extends Abba { public Bar(String id) { super(id); } public void one() { two(); } public void three() { System.out.print("B3 " + getID()); } } //////////////////////////////////// class Goo extends Bar { public Goo(String ID) { super("X" + ID + "X"); } public void two() { System.out.print("G2 "); super.three(); } public void three() { System.out.print("G3 "); } }
public class Point { private int my_xPos; private int my_yPos; public Point(int x, int y) { my_xPos = x; my_yPos = y; } public int getX() { return my_xPos; } public int getY() { return my_yPos; } }