True Statements from your Multiple Choice Questions for Exam 1. Java allows automatic conversions from char to int. 2. Overloaded methods have the same name but different parameters. 3. Static duration means the variables and methods exist from the point at which the class in which they are defined is loaded into memory for execution until the program terminates. 4. The value of row 1, column 2 in the following array is: 6 int array1[][] = { {1,2,3}, {4,5,6}}; 5. int a[12]; is NOT a legal java statement. 6. If an entire array is passed to a method, any modifications to the array elements will be reflected in the original 7. public Currency (double x) is a valid constructor for the Currency class. This class accepts a double as an argument and converts that double to a String value. 8. The following statement is not a valid way to compare two strings: if ( stringa.equalTo(stringb) ) {}; 9. s1.concat(s2) has the following effect: s2 is appended to the results of s1, but neither s1 or s2 are modified 10. The layout of a container can be altered using the following method: setLayout(aLayoutManager); 11. mouseMoved is not a method in interface MouseListener. 12. The following is a valid java statement: add (button1, BorderLayout.NORTH); 13. The addActionListener method is one that is likely to be used with a button. 14. The FlowLayout manager honors the preferred size of a component. 15. The halt( ) method will not cause a thread to stop executing. 16. Elements declared as private cannot be inherited by the subclass. 17. Super is the keyword that is used to invoke an object's superclass constructor. 18. An interface contains methods and constants. 19. When you can have various methods with the same name that each operate on different types and/or number of arguments, it is called overloading. 20. The number used to refer to a particular element of an array is called the subscript. 21. Class members are accessed via the dot operator in conjunction with an object of the class. 22. A constructor is a special method used to initialize the instance variable of a class. 23. A set method is used to assign values to private instance variable of a class. 24. A get method is used to retrieve values of private data of a class. 25. An object of a subclass can be treated as an object of its corresponding superclass. 26. S1.length( ) can be used to determine the length of the string S1. 27. GUI stands for "Graphic User Interface" 28. The add method for attaching GUI components to an applet or panel is a container class method. 29. The stop method is used to terminate a thread and sleep method halts running thread given amount of time. 31. The following is a correct Java statement: String temp[] = {"a", "b", "c"}; 32. The correct declaration of an abstract method which is intended to be public is: public abstract void add(); 33. You obtain a default constructor under this situation: When the class has no other constructors. 34. Given the following code: public class Test{ . . . . . . } The method public Test(){...} can be used to define a constructor for class Test. 35. Any type is a legal return type of a method overloading the following method: public void add(int a) {. . .} 36. The overriding method must return void if it is overriding the following method: public void add(int a) {. . .} 37. In a constructor, you can only place a call to the constructor defined in the super class as the first statement in the constructor. 38. Runnable is the name of the interface which can be used to define a class which can execute within its own thread. 39. The name of the method used to schedule a thread for execution is: start() 40. The notify( ) method may not cause a thread to stop executing. 41. Using a FlowLayout manager, the correct way to add elements to a container is: add(component) 42. A valid return type for listener methods is void. 43. Assuming we have a class which implements the ActionListener interface, the method that should be used to register this with a Button is: addActionListener( ); 44. The values 3 and 4 are printed out as the result of executing the following code when the value of x is 2: switch (x) { case 1: System.out.println(1); case 2: case 3: System.out.println(3); case 4: System.out.println(4); } 45. If a return-value-type other than void is specified, the method must contain a return statement. 46. When a variable is declared in method definitions, it is considered a local variable. 47. The technique of sorting for ascending values, low to high, is called the bubble sort. 48. The linear search method works well for small arrays. 49. The name of a constructor is always the name of the class, 50. Deriving new classes from existing classes is called inheritance. 51. Subclass methods and methods of other classes in the same package as the superclass can access protected superclass members. 52. If class Monkey inherits from the class Ape, then class Ape is called the superclass. 53. When references are compared with ==, the result is true if both references refer to the same object in memory. 54. String method length returns the number of characters in a String. 55. Choice buttons implement ItemSelectable, which indicates that Choice buttons generate item events. 56. GUIs are event driven. 57. TextComponent method setText( ) places text in a TextArea. 58. Java is multi-threaded language. 59. A suspended thread is made active by calling resume method. 60) Two kinds of class members of an ADT are: data members and method members. 61) public and private are keywords that are member access modifiers. 62) Instances of the class are called class objects. 63) Instances of the class are instantiated by using the keyword new. 64) The definition of a class creates a user-defined data type. 65) A class constructor is a member method whose purpose is to initialize the private instance variables of a class object. 66) The name of a constructor is always the name of the class. 67) Methods that get the values of private instance variables are called "getters" 68) Methods that set the values of private instance variables are called "setters" 69) Private methods used to support the operation of other class methods are called: utility (or helper) methods 70) A Label is an area where uneditable text can be displayed. 71) Choice and Checkbox objects generate "item events" that can be processed by any ItemListener object. 72) FlowLayout is the default for Applets and Panels. 73) BorderLayout arranges the components into five areas:North,South,East,West, and Center. 75) GridLayout arranges the components into rows and columns. 76. The keyword final creates a variable that cannot be changed. 77. A method is considered overloaded if: two methods have the same name but different parameter lists. 78. The number of values you can return from a method is 1. 79. A recursive method is a method that calls itself. 80. Arrays start at subscript: 0 81. The statement public class cat extends mammal creates a subclass cat that inherits from superclass mammal. 82. the keyword private allows only the class that it was created in to access it. 83. The method run( ) must be defined if you implement Runnable. 84. In calling Thread.sleep(a), parameter a is measured in milliseconds. 85. The keyword public allows access by all methods in the entire program. 86. A subclass cannot inherit from more than one superclass. 87. A superclass can use its own private data in its methods. 88. The statement if ( true && false ) evaluates to: if ( false ) 89. The statement if ( true || false ) evaluates to: if ( true ) 90. The statement public class Animation extends Applet implements Runnable is used to define a subclass Animation that inherits from Applet and implements Runnable interface. 91. The statement System.out.println ("Enter"); outputs the word Enter on the screen. 92. The classes that are used to create GUI interfaces are located in the java.awt package. 93.The statement g.drawString ("Face", 35, 40); displays the word Face at x=35 y=40 on the applet. 94. The statement pointLabel = new Label ("Point is") constructs a label displayed as: Point is 95. repaint is a method. 96. There are 10 numbers in the array int [10] 97. The first subscript of the array int [10] is 0. 98. getHour is a get method. 99. setTime is a set method 100. The following statement g.fillOval(10,10,50,50); draws a circle with 25 radius and fills it with the current drawing color. 101. Keyword super is used to invoke an object's superclass constructor. 102. An abstract method lacks a method body. 103. Interfaces in the EventListener include: KeyListener, MouseListener, ActionListener. 104. Keyword this refers to the object in which it is used. 105. Java provides a number of classes that enable the primitive data types to be treated as objects. Some of these wrapper classes are: Boolean, Character, Double, Float, Byte, Short, Integer, and Long. 106. Most Character class methods are static methods. 107. Class StringBuffer provides 10 overloaded append methods. 108. Public members of a superclass are accessible by all methods in the program. 109. A Graphics object must be used to draw. 110. The setColor method set the current color to the Color object constructed with the red, green, and blue values. 111. The graphics method drawRect draws a rectangle with the specified upper-left corner, width and height. 112. The graphics method setFont sets the current font. 113. A StringBuffer is used to implement the concatenation operator for String class. 114. The Dot operator associates from left to right.