This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Could someone please review this for correctness??
Posted by Steve on May 05, 2000 at 3:42 PM
While trying to learn Java, I'm making flashcards until I get the basics down. I'd be grateful if you could review the Q/A's below and send any corrections to: yaeger2@gateway.net I'd also appreciate any new Q/A's for my flashcards or elaborations on Q/A's below. Thanks, Steve Q1 Explain the appearance of a constructor, when compared to a method.
A1 A constructor looks like a method, but it lacks a return type. Q2 Identify constructors and initializers in class CoffeeCup: class CoffeeCup { private int innerCoffee; //.. } A2 There are none.
Q3 Declare an uninitialized array of Point named myPoints.
A3 Point myPoints[]; Q4 In the code below, allocate an array of ten references to Point, called myPoints, that are initialized to the null reference: Point myPoints[]; A4 myPoints = new Point[10]; (note: invalid??)
Q5 Which string object is for read-only objects ?
A5 The String class is for read-only objects. Q6 Which string object is for modifiable objects ?
A6 The StringBuffer class is for objects that can be modified. Q7 String objects provide ? to obtain the number of characters in a string.
A7 String objects provide the length() accessor method to obtain the number of characters in a string. Q8 A class definition has some or all of which six items ?
A8 class variables, instance variables, class methods, instance methods, constructors, and static initializers Q9 What is a class ?
A9 A class is a master copy of an object that determines what behavior and attributes the object should have. Q10 What's the format of a class called Dog ?
A10 [keywords] class Dog [extends Superclass] [implements Interface] { // class body } Q11 What's a class variable ?
A11 A class variable is associated with a class of objects, not just a single object. Q12 What is AWT ?
A12 AWT stands for Abstract Windowing Toolkit; a set of Java classes that has been extended by the Swing windowing classes. They can be used to display and control a GUI. Q13 What is an argument ?
A13 An argument is extra info that is either sent to a program at runtime (via the command prompt), or sent to a method during a program. Q14 What is an array ?
A14 An array is a group of variables that share the same name and store the same kind of info. Q15 public Virus(String name, int size) { author = name; maxFileSize = size; } Write an example of code that could be used to call the above constructor.
A15 Virus mumps = new Virus("Hall", 30000); or the format.... Virus [reference] = new Virus("[string]", integer); Q15 public Virus(String name, int size) { author = name; maxFileSize = size; } The above constructor could be called only if ?
A15 In the example code, the constructor could be called only if a string and an integer were sent as arguments, along with the new statement. Q16 In OOP, what's an attribute do ?
A16 An attribute describes an object and distinguishes it from others. Q17 Where are attributes kept ?
A17 Attributes are stored in variables.
Replies:
|