CS 162 Final

Descripción

Review for final in CS 162 for Spring Term, 2014 at Western Oregon State. Questions were taken from quizzes one to five.
jshin13
Fichas por jshin13, actualizado hace más de 1 año
jshin13
Creado por jshin13 hace más de 10 años
91
1

Resumen del Recurso

Pregunta Respuesta
The type of errors that the compiler will NOT detect are known as: Semantic errors
The method ____ of an Iterator<E> object returns an object of type E from the container that has not yet been accessed by this iterator instance. next( )
Some of the commonly used public methods of an Iterator object are: hasNext() and next() and remove()
If the expression, pet1.setName("Socrates"), is a valid method call, which of the following MUST be true about the setName() method? It takes one parameter, a String variable.
What do you call a section of code that is written in a natural language (like English), which is ignored by the compiler and is intended for people to read? Comments
A variable that is declared as "final" is known as a ___. constant
What is the purpose of a mutator method? To change the state of an object.
Altering the flow of a program by making a choice is called a(n) ________ statement. conditional
“Coupling” refers to Logical linkage between separate units of a program that interfere with reusability
The BlueJ tool called a/an _____ is used to view the current value (state) of an objects fields. debugger
The signature of a method consists of... the type of its parameters, name of the method, the number of its parameters
A collection of objects and defined states to setup scenarios for several test are know as: Test Fixtures
Given the string declarations below, what is the value of s3 == s2? String s1 = new String("foo"); String s2 = new String("foo"); String s3 = s2; true
What are two key components of Java objects? Java objects have fields and methods.
A Java "HashMap" container is best described as: A container where elements in the container are accessed via an unique value that has been associated with a data element.
Say that a particular item of data is NOT a primitive data type. What must it be? An object.
If the initial condition of any "while" loop is false it will still execute once. False
Examine the following code: int[] numList = new int[4]; int accumulator = 0 for( int index = 0; index < 4; index++) { accumulator = accumulator + index; numList[index] = accumulator; } What will be the value stored in numList[3] after the for loop completes? 6
What type of instruction uses the equal sign (=) symbol? Assignment
“Cohesion” refers to The number and diversity of tasks that a program unit implements
The part of a method definition that serves as a place holder for data passed to the method is known as a parameter
String variables are primitive variable types. false
Examine the following code: int count = 1; while ( ___________ ) { System.out.print( count + " " ); count = count + 1; } System.out.println( ); What condition should be used so that the code writes out: 1 2 3 4 5 6 7 8 count < 9
What is a class? A class is a description and definition of the type of an object.
Loop indentation is important because it makes the loop structure more readable.
Another word for "looping" is: iteration
To guard against infinite loops you must insure that _____ the loop variable is updated in each pass of the loop.
What method has the same name as the class name, and is used to perform the initial setup operations for class instance variables? Constructor
What is another name for creating an object? instantiation
Copy of Given the string declarations below, what is the value of s1 == s2? String s1 = new String("foo"); String s2 = new String("foo"); String s3 = s2; false
Which of the following is true of a constructor method? If a class contains no constructor declarations, Java will automatically supply a default constructor, A constructor is one way to initialize an object's instance variables, A constructor method cannot have a return type.
The type of errors that the compiler will detect are known as Syntax errors
Say that there are four classes: Book, Magazine, Newpaper, Publication. What are the likely relationships between these classes? Publication is the superclass, Book, Magazine, and Newspaper are subclasses of Publication.
Does a superclass inherit both member variables and methods? No - neither can be inherited by the superclass.
Which of the following pertains to polymorphic variables? When a program uses several different types of objects, each with its own variable.
What restriction is the on using the super( ) call in a constructor? It must be used in the first statement of the constructor.
Which of the following is an advantage to using inheritance? Code that is shared between classes needs to be written only once.
How can you tell when information is being passed to the constructor of the parent class? The parameter, either actual or passed into the child class, is passed through the super() call in the constructor of the child class.
If you have two classes, Hamster and Animal, where Hamster is a subclass of Animal, what is the correct class header for Hamster? class Hamster extends Animal
Can an object be a subclass of another object? No—inheritance is only between classes.
Does a subclass inherit both member variables and methods? Yes - Both are inherited
Which of the following is NOT an advantage to using inheritance? One big superclass can be used instead of many little classes.
How can you tell when a constructor is being called in a program? The keyword new is present
Which of the following is one form of polymorphism in Java? When a class has several methods with the same name but different parameter types.
What is an advantage of polymorphism? The same program logic can be used with one objects of several related types.
When a class implements an interface, what must it do? It must declare identical signatures and provide a method body for each method signature in the interface.
What two things must your program do to respond to a particular type of event? Create an event listener object for the type of event, and register it with the object that generates those events.
In Java, what do you call an area on the screen that has nice borders and various buttons along the top border? A frame.
The DYNAMIC type of any variable refers to the actual run-time type of the real object that the variable holds a reference to.
The STATIC type of any variable refers to the declared compile-time type of the the variable.
Can an abstract parent class have non-abstract children? Yes—an abstract parent can have both abstract and non-abstract children.
What is an abstract class? An abstract class is class which cannot be instantiated.
What must be true if a child of an abstract parent class does not override all of the parent's abstract methods? The child class itself must be declared to be abstract.
An object that waits for and responds to an event from a GUI component is a: event listener
Here is an abstract method defined in some abstract parent class: public abstract int sumUp ( int[] arr ); Which of the following is required by all of it's non-abstract child classes? public int sumUp ( int[] arr ) { . . . }
How is a GUI component (such as a button) placed into a JFrame? getContentPane().add( Component c )
What letter do many Swing class names start with? J
Can an abstract class define both abstract methods and non-abstract methods? Yes - but the child classes must define the body of abstract methods
What must be true if a child of an abstract parent class does not override all of the parent's abstract methods? The child class itself must be declared to be abstract.
What is an abstract method? An abstract method is one without a body that is declared with the reserved word abstract.
When a class implements an interface, what must it do? It must declare identical signatures and provide a method body for each method signature in the interface.
Can an interface ever contain method bodies? No.
A child class can extend ___ parent(s) and can implement ___ interfaces. just one parent; zero or more interfaces
What is an abstract class? a class which cannot be instantiated.
Can an interface name be used as the type of a variable? Yes - the variable can refer to any object whose class implements the interface.
What method is used to read the text from a JTextField? getText()
[T/F] A checked exception is any exception checked for by the compiler. True
____ is when a program is written to respond to button clicks, menu selections, user actions Event-driven programming
When the user clicks on a button, what is generated? An event
What is a container object in GUI programming? A container is a GUI component that has other GUI containers placed inside of it.
Which of the following is an exception thrown by the methods of the class String? NullPointerException
In which of the following layout managers do all rows (columns) have the same number of components and all components have the same size? GridLayout
When is a finally{} block executed? Always after the execution of a try block, regardless of whether or not an exception is thrown.
How many finally blocks can there be in a try/catch structure? There can be 0 or 1 following the last catch block.
If the user changes the size of the frame, what happens to the graphical components? The layout manager changes the layout and redistributes the components.
Every try block: must have one or more catch blocks
What can a method do with a checked exception? Throw the exception to the method that called this method, or handle the exception in a catch block.
What happens when there is no catch block following the try block? The program will not compile
What is the purpose of the Graphics object? It provides the underlying framework for java graphics operations
What type of object determines where GUI components go in the content pane? The layout manager
Which manager displays components in the possible locations of north, south, east, west, center? BorderLayout
Must a program respond to all events that its components generate? No - it can safely ignore events that don't concern it
Components must be added to the window's ___ content pane
Which manager displays components row-by-row, in order in which they were added? FlowLayout
If a negative value is used for an array index, what exception is thrown? IndexOutofBoundsException thrown
What is the name for a method that responds to events? listener method
How does BoxLayout() put components into the content pane? Either top to bottom (vertical), or left to right (horizontal)
The fundamental classes for GUI programming are contained in the: Abstract Windowing Toolkit
Which class of exceptions is NOT checked? RunTimeException
An abstract variable V is a mutable entity that admits two operations: store(V, x), fetch(V)
An implementation detail, such as whether a method is recursive or iterative, should usually be ______ from the user. hidden
A description of a software design pattern includes at least: the consequences of using the pattern, the description of the problem that the pattern addresses, a name that can be used to conveniently talk about the pattern, a description of the solution
If a recursive algorithm does not make progress toward the base case, it could _____ run forever or until the method call stack overflowed.
A suggested approach to discover the initial potential classes for a project is to extract the following from the project description and use cases: List all of the verbs encountered.
[T/F] A "singleton" design pattern is used to ensure that only ONE instance of a class can be created. true
[T/F] Scenarios are very technical problem descriptions that are best written by software engineers rather than the people familiar with the business problem. false
The operations that modify a stack are: push(), pop()
[T/F] A design pattern is a description of a common computing problem and a description of a small set of classes and their interaction structure that helps to solve that problem. true
What are some of the key ACTIVITIES in software development? Definition, Analysis, Design, Implementation, Deployment
A recursive definition is commonly one which defines the nth case in terms of the ______ case. n - 1
An iterative method ___ uses less memory than a recursive method, uses some kind of loop as a control structure, is usually more efficient to execute than a recursive method
What are two parts to recursion? (1) Directly solve the any of the easy problems, and (2) Decompose the harder problem into subproblems; solve the original problem in terms of the solutions to the subproblems.
What are two ways to view recursion? i. static view; ii. dynamic view
Consider square numbers defined as follows: square(1) = 1 square(N) = square(N-1) + 2N -1 According to this definition, what is square(3)? square(3) = square(2) + 2*3 - 1
Say that you have an recursive Java method, compute(). Is it always possible to write a iterative version of compute( )? Yes
The FACTORY design pattern's primary purpose is to: create instances of objects
A base case is that part of a recursive definition that stops the recursion from cycling endlessly.
[T/F] A "singleton" design pattern is used to ensure that only ONE instance of a class can be created. True
Mostrar resumen completo Ocultar resumen completo

Similar

Data Structures
Ruth Hyndman
Data Legislation
Jp Pennington
Malware quiz
14lwright
Computer System
Dhanil Capil
BA 211 Week 1 Vocab
jshin13
CS 162 Final 1
jshin13
BA310 -- Midterm 1 Practice
jshin13
CS TOPIC 3 - NETWORK
Sacha Pierre
Prefijos y sufijos
Frida Estrada
Starter Quiz
chalfpenny
Metodologias Agiles y RUP
Elkin Vargas02