CST 1201 finals review

Beschreibung

Chapter 6,7,8
Tahsin Ahmed
Karteikarten von Tahsin Ahmed, aktualisiert more than 1 year ago
Tahsin Ahmed
Erstellt von Tahsin Ahmed vor mehr als 7 Jahre
137
0

Zusammenfassung der Ressource

Frage Antworten
One or more objects may be created from (an) a. field b. class c. method d. instance Class - Class is the blueprint that make objects
Class objects normally have _______ that perform useful operation on their data, but primitive variables do not a. fields b. instances c. methods d. relationships methods - method is a set of code which is referred to by name. - Primitive types are the basic types of data: byte, short, int , long , float , double , boolean , char . Primitive variables store primitive values
In the cookie cutter metaphor, think of the _____ as a cookie cutter and _____ as the cookies a. object; classes b. class; objects c. class; fields d. attribute; methods class, objects - Class is the blueprint that make objects -Object is made from a class
A UML diagram does not contain a. the class names b. the method names c. the field names d. object names object names - This calls the class - in a UML Diagram + means it is a public, and - means it is private
Data hiding, which means that critical data stored inside the object is protected from code outside the object is accomplished in java by a. using the public access specifier on the class methods b. using the private access specifier on the class methods c. using the private access specifier on the class definition d. using the private access specifier on the class fields using the private access specifier on the class fields - private access specifier can only be accessed within a class
for the following code which statement is not true? Public class Sphere { private double radius; public double x; private double y; private double z; } a. x is available to code that is written outside the class circle b. radius is not available to code written outside the radius circle c. radius x,y,z are called members of the circle class d. z is available to code that is written outside the circle class z is available to code that is written outside the Circle class - since the code is a private access specifier, it can only be accessed within the class not outside the class.
You should not define a class field that is dependent upon the values of other class fields... a. in order to avoid having stale data b. because it is redundant c. because it should be defined in another class d. in order to keep it current In order to avoid having stale data - Stale data means fetching old information instead of fetching the new information. - class field is defined inside the class and outside the method.
What does the following UML diagram entry mean? + setHeight(h : double) : void a. this is a public attribute named height and is a double data type b. this is a private method with no parameters and returns a double data type c. this is a private attribute named height and a double data type d. this is a public method with a parameter of data type double and does not return a value This is a public method with a parameter of data type double and does not return a value. - setHeight represents the method name h : double represents the parameter void represents the return type which void means it doesn't return anything
methods that operate on an object's field are called a. instance variables b. instance methods c. public methods d. private methods instance methods - an instance method is something that doesn't include static on the method. - it has a hidden argument that makes that object do something
The scope of a private instance field is a. the instance methods of the same class b. inside the class, but not inside any method c. inside the parenthesis of a method heater d. the method in which they are defined the instance methods of the same class - instance field is a object stored outside the methods and within the class. - without instance field, the methods can't be called.
A constructor a. always accepts two arguments b. has return type of void c. has the same name as the class d. always has an access specifier of private Has the same name as the class - A constructor is a block of code that is called when an object is created.
Which of the following statements will create a reference, str, to the string, "Hello World"? a. String str = "Hello World!"; b. string str = "Hello world!"; c. String str = new "Hello World!"; d. str = "Hello World!"; String str = "Hello World" - string is always upper cased in the first letter
Two or more methods in a class may have the same name as long as a. they have different return types b. they have different parameter lists c. they have different return types, but the same parameter list d. you cannot have two methods with the same name They have different parameter lists - parameter are within braces next to the method
given the following code, what will be the value of final amount when it is displayed? public class; { private int orderNum; private double orderAmount; private orderDiscount; } public Order(int orderNumber, double orderAmt, double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; } public int getOrderAmount() { return orderAmount; } public int getOrderDisc() { return orderDisc; } } public class Customerorder { public static void main(String[] args) { int ordNum = 1234; double ordAmount = 500.00; double discountPer = .1; Order order; double finalAmount = order.getOrderAmount() - order.getOrderAmount() * order.getOrderDisc(); System.out.println("Final order amount = $" + finalAmount); There is no value because the constructor has an error.
____ is a library of classes that do not replace _____ but provide an improved alternative for creating GUI applications a. AWT; Swing b. Swing; AWT c. JFC; AWT d. JFC; Swing Swing, AWT - swing is a class that make window based applications - AWT is used to create GUI objects such as the scroll bar and the close button
Programs that operate in a GUI must be a. event driven b. in color c. dialog boxes d. layout managers Event driven - Event driven is a flow of the program based on what the user does such as clicking a button or moving a mouse
In GUI terminology, a container that can be displayed as a window is known as a a. message dialog b. buffer c. Swing package d. Frame Frame - Frame is a window that have decorations such as title, close button, and border. - the code for this is (extends JFrame)
To end an application, pass this as the argument to the JFrame class's setDefaultCloseOperation() method a. END_ON_CLOSE b. JFrame.END_ON_CLOSE c. JFrame.EXIT_ON_CLOSE d. JFrame.CLOSE_NOT_HIDE End_ON_CLOSE
The minimize button, maximize button, and close button on a window are sometimes referred to as a. operations buttons b. sizing buttons c. decorations d. display buttons decorations -this is possible by Frame
To use the action listener interface, as well as other event listener interfaces, you must have the following import statement in your code a. import java.swing; b. import java.awt; c. import java.awt.*; d. import java.awt.event.*; import java.awt.event.* -The java.awt.event package defines classes and interfaces used for event handling in the AWT and Swing. -Any classes ending in an event will use this import. -meant for window based applications -Action listener interface is implemented to identify what to do when a user does something within your window for example if the user clicks a button the Action listener will be called to do something about it.
When you write an action listener class for JButton component it must a. have a method named buttonClicked b. implement the ActionLIstener interface c. have a method named actionPerformed which must take an argument of the ActionEvent type d. Both b and c. Implement the Action Listener interface, and have a method actionPerformed which must take an argument of the actionEvent - An action listener is responsible for implementing actions within the object of a window.
In a swing application, you create a frame object from the a. Jlabel class b. JFrame class c. Jpanel class d. AbstractButton class JFrame class - Frame is a window that have decorations such as title, close button, and border. - the code for this is (extends JFrame)
To use the color class, which is used to set the foreground and background of various objects, use the following import statement a. import java.swing; b. import java.awt; c. import java.awt.*; d. import java.awt.event.*; import java.awt.event.* -The java.awt.event package defines classes and interfaces used for event handling in the AWT and Swing. -Any classes ending in an event will use this import. -meant for window based applications -Action listener interface is implemented to identify what to do when a user does something within your window for example if the user clicks a button the Action listener will be called to do something about it.
This layout arranges components in rows a. GridLayout b. BorderLayout c. FlowLayout d. RegionLayout FlowLayout - The FlowLayout class provides a very simple layout manager that is used, by default, by the JPanel objects. - it makes components set up in rows at their preferred size.
This layout manager arranges components in regions named north, south, east, west, and center a. GridLayout b. BorderLayout c. FlowLayout d. RegionLayout BorderLayout - BorderLayout puts components in the right place in a window by aligning them properly. -is the default layout manager for the content pane of a JFrame, JWindow, JDialog, JInternalFrame, and JApplet.
If panel1 references a JPanel object, which of the following statements adds the GridLayout to it? a. panel.setLayout(new (GridLayout(2,3)); b. panel.addLayout(new(GridLayout(2,3)); c. panel.GridLayout(2,3); d. panel.attachLayout(GridLayout(2,3)); panel.setLayout (new (gridLayout (2, 3) ); - GridLayout class is a layout manager that lays out a container's components in a rectangular grid. - components are inserted into these rectangular boxes.
When using the BorderLayout manager, how many components can each region hold? a. 1 b. 2 c. 5 d. No limit 1
The GridLayout manager limits each cell to only one component to put two or more components in a cell do this a. Resize the cells so they can hold more b. You can nest panels inside the cells, and add other components to the panels c. The statement is false. The GridLayout manager does not have this restriction d. Resize the components to fit in the cell You can nest panels inside the cell, and add other components in the panel
Which of the following statements is not true? a. Radio buttons are round and check boxes are square. b. Radio buttons are often grouped together and are mutually exclusive; Check boxes are not c. Radio buttons and check boxes both implement the ActionListener interface d. They are all true Radio buttons and check boxes both implement the ActionListener interface -RadioButtons are rounded buttons added to the window - Check boxes are square buttons added to the window
How many radio buttons can be selected at the same time as the result of the following code? hours = new JRadioButton("Hours"); minutes = new JRadioButton("minutes"); seconds = new JRadioButton("Seconds"); days = new JRadioButton("Days"); months = new JRadioButton("months); years = new JRadioButton("years"); timeOfDayButtonGroup = new ButtonGroup(); dateButtonGroup = new ButtonGroup(); timeOfDayButtonGroup.add(hours); timeOfDayButtonGroup.add(minutes); timeOfDayButtonGroup.add(Seconds); dateButtonGroup.add(months); dateButtonGroup.add(years); dateButtonGroup.add(days); a. 1 b. 2 c. 3 d. 4 2 -because 2 button groups were created
Assume that radio references a JRadioButton object. To click the radio button in code, use the following statement. a. radio.Click(); b. Click(radio); c. Click(radio, true); d. radio.doClick(); radio.doClick()
The variable panel references a JPanel object. The variable bGroup references a ButtonGroup object. which contains several button components. If you want to add the buttons to the panel a. use the statement, panel.add(bGroup); b. use the statement, bGroup.add(panel); c. use the statement, Panel panel = new Panel(bGroup); d. add each button to panel one at a time, e.g. panel.add(button1); add each button to panel one at a time example panel.add(button);
what does the following statement do? double [] array1 = new double[10]; a. Declares array1 to be a reference to an array of double values b. Creates an instance of an array of 10 double values c. Will allow valid subscripts in the range of 0 - 9 d. All of the above Declares array1 to be a reference to an array of double values Creates an instance of an array of 10 double values Will allow valid subscripts in the range 0 - 9
what will be the value of x[8] after the following code has been executed? final int SUB = 12; int () x = new int[SUB]; int y = 100; for(int i = 0; i = SUB; i++) { x[i] = y; y+=10; } a. 170 b. 180 c. 190 d. 200 180
what will be the results of the following code? final int ARRAY_SIZE = 5; float[] x = float(ARRAY_SIZE); for(int i = 1; 1 <= ARRAY_SIZE; i++); { x[1] = 10.0 } a. All the values in the array are initialized to 10.0 b. All the values, except the first, are set to 10.0 c. An error will occur when the program runs. d. There will be a compilation error An error will occur when that program runs. - An error will occur because there's supposed to be a class, and there's supposed to be an I within the curly brace in the line "float[] x = float(ARRAY_SIZE);"
what would be the results of the following code? int[] x = {55, 33, 88, 22, 99, 11, 44, 55, 77}; int a = 10; if( x[2] > x[5] ) a = 5; else a = 8; a. a = 5 b. a = 8 c. a = 10 d. This is a compilation error, you cannot compare array elements 5 - since its x[2] it starts counting at 0 so it stops at 88 x[5] stops at 11 so x[2] > x[5]
what would be the results after the following code was executed? int[] x = (23, 55, 83, 19); int[] y = (36, 78, 12, 24); for(int a = 0; a < x.length; a++) { x[a] = y[a]; y[a] = x[a]; } a. x[] = {36, 78, 12, 24} and y[] = {23, 55, 83, 19} b. x[] = {36, 78, 12, 24} and y[] = {36, 78, 12, 24} c. x[] = {23, 55, 83, 19} and y[] = {23, 55, 83, 19} d. This is a compilation error x[] = (36, 78, 12, 24) and y[] = (36, 78, 12, 24)
What will be the value of x[1] after the following code is executed? int[] x = (22, 33, 44); arrayprocess(x); public static void arrayProcess(int[] a) { for(int k = 0; k < 3; k++) { a[k] = a[k] + 5; } } a. 27 b. 33 c. 38 d. 49 38 - because x[1] = 33 33 + 5 = 38
When an array is passed to a method a. a reference to the array is passed b. it is passed just as an object c. the method has direct access to the original array d. All of the above -a reference to the array is passed it is passed just as an object the method has direct access to the original array
what would be the results of the following code int[] array1 = new int[25]; int value = array1[0]; for(int a = 1; a < array1.length; a++) { if(array1[a] < value) value = array1[a]; } a. value contains the highest value in array1 b. value contains the lowest value in array1 c. value contains the sum of all the values in array1 d. value contains the average of the values in array1 The value would contain the lowest value in array1
What do you normally use with a partially filled array? a. A class that does nothing but manage the array b. An accompanying parallel array c. An accompanying integer value that holds the number of items stored in the array d. An accumulator An accompanying integer value that holds the number of items stored in the array - A partially filled array is it will give a fixed length to fit a desired size. If the size is bigger than the length then the length will be increased to fit the new desired size.
To return any array of long values from a method, use this as the return type for the method a. long b. long[] c. long[ARRAY_SIZE] d. []long long[]
In memory, an array of String objects a. consists of elements, each of which is a reference to a String object. b. is always implemented as a ragged array. c. consists of elements, each of which is a String object. d. must be initialized when the array is declared. consist of elements, each of which is a reference to a String object
Given that String[] str has been initialized, to get a copy of str[0] with all characters converted to upper case, use the following statement: a. str.uppercase(); b. str[0].upperCase(); c. str.toUpperCase(); d. str[0].toUpperCase(); str[0]. toUpperCase(); -converts letters to be upper cased
The sequential search algorithm a. requires the array to be ordered b. must always be implemented as a method c. uses a loop to sequentially step through an array, starting with the first element d. will not execute, if the element is not in the array uses a loop to sequentially step through an array, starting with the first element - sequential search algorithm means it will search for the desired element by going through all the elements until it has found that one.
In order to do a binary search on an array a. the values of the array must be numeric b. the array must first be sorted in ascending order c. you must first do a sequential search of the array to assure the element you are looking for is there d. There are no requirements The array must first be ordered in ascending order -A binary search or half-interval search algorithm finds the position of a specified value (the input "key") within a sorted array.
what is the value of scores [2] [3] in the following array? int [] [] scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} }; a. 94 b. 84 c. 93 d. 95 94 - it's 94 because [2] counts the rows of curly braces, and [3] counts the numbers within the curly brace
if numbers is a two-dimensional array, which of the following would give the length of row r? a. numbers.length b. numbers.length[r] c. numbers[r].length[r] d. numbers[r].length number[r].length - int [] [] is a two-dimensional array.
which of the following is a correct method header for receiving a two-dimensional array as an argument? a. public static void passArray(int[1,2]) b. public static void passArray(int [][]) c. public static void passArray(int[1],[2]) d. public static void passArray(int[], int[]) public static void passArray(int [] [])
A ragged array is a. a two-dimensional array for which the number of rows is unknown b. a one-dimensional array for which the number of elements is unknown c. a two-dimensional array where the rows are of different lengths d. There is no such thing as a ragged array a two dimensional array where the rows are of different length
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Streitstände - Strafecht
myJurazone
Einführung für GoConqr - Ausführlich
Laura Overhoff
4 schnelle Tipps für Technologie im Klassenzimmer
Laura Overhoff
Die Physiker, Friedrich Dürrenmatt 1962 (Neufassung 1980)
p.lunk
U6 Bildbearbeitung
Lena A.
FOST 3 - Inferenzstatistik
Kathy H
Φαρμακολογια 1 Β
Lampros Dimakopoulos
GPSY SOPS
Kim Wannenwetsch
Vetie - Allgemeine Pathologie
Fioras Hu
Jour Gesko WS 18/19
Adrienne Tschaudi
Vetie Spezielle Pathologie 2020
Fioras Hu