Flashcards
CS 162 Final
Cards in this deck (108)
- 1The type of errors that the compiler will NOT detect are known as:Semantic errors
- 2The method ____ of an Iterator object returns an object of type E from the container that has not yet been accessed by this iterator instance.next( )
- 3Some of the commonly used public methods of an Iterator object are:hasNext() and next() and remove()
- 4If 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.
- 5What 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
- 6A variable that is declared as "final" is known as a ___.constant
- 7What is the purpose of a mutator method?To change the state of an object.
- 8Altering the flow of a program by making a choice is called a(n) ________ statement.conditional
- 9“Coupling” refers toLogical linkage between separate units of a program that interfere with reusability
- 10The BlueJ tool called a/an _____ is used to view the current value (state) of an objects fields.debugger
- 11The signature of a method consists of...the type of its parameters, name of the method, the number of its parameters
- 12A collection of objects and defined states to setup scenarios for several test are know as:Test Fixtures
- 13Given 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
- 14What are two key components of Java objects?Java objects have fields and methods.
- 15A 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.
- 16Say that a particular item of data is NOT a primitive data type. What must it be?An object.
- 17If the initial condition of any "while" loop is false it will still execute once.False
- 18Examine 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
- 19What type of instruction uses the equal sign (=) symbol?Assignment
- 20“Cohesion” refers toThe number and diversity of tasks that a program unit implements
- 21The part of a method definition that serves as a place holder for data passed to the method is known asa parameter
- 22String variables are primitive variable types.false
- 23Examine 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 8count < 9
- 24What is a class?A class is a description and definition of the type of an object.
- 25Loop indentation is important becauseit makes the loop structure more readable.
- 26Another word for "looping" is:iteration
- 27To guard against infinite loops you must insure that _____the loop variable is updated in each pass of the loop.
- 28What method has the same name as the class name, and is used to perform the initial setup operations for class instance variables?Constructor
- 29What is another name for creating an object?instantiation
- 30Copy 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
- 31Which 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.
- 32The type of errors that the compiler will detect are known asSyntax errors
- 33Say 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.
- 34Does a superclass inherit both member variables and methods?No - neither can be inherited by the superclass.
- 35Which of the following pertains to polymorphic variables?When a program uses several different types of objects, each with its own variable.
- 36What restriction is the on using the super( ) call in a constructor?It must be used in the first statement of the constructor.
- 37Which of the following is an advantage to using inheritance?Code that is shared between classes needs to be written only once.
- 38How 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.
- 39If 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
- 40Can an object be a subclass of another object?No—inheritance is only between classes.
- 41Does a subclass inherit both member variables and methods?Yes - Both are inherited
- 42Which of the following is NOT an advantage to using inheritance?One big superclass can be used instead of many little classes.
- 43How can you tell when a constructor is being called in a program?The keyword new is present
- 44Which of the following is one form of polymorphism in Java?When a class has several methods with the same name but different parameter types.
- 45What is an advantage of polymorphism?The same program logic can be used with one objects of several related types.
- 46When 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.
- 47What 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.
- 48In Java, what do you call an area on the screen that has nice borders and various buttons along the top border?A frame.
- 49The DYNAMIC type of any variable refers tothe actual run-time type of the real object that the variable holds a reference to.
- 50The STATIC type of any variable refers tothe declared compile-time type of the the variable.
- 51Can an abstract parent class have non-abstract children?Yes—an abstract parent can have both abstract and non-abstract children.
- 52What is an abstract class?An abstract class is class which cannot be instantiated.
- 53What 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.
- 54An object that waits for and responds to an event from a GUI component is a:event listener
- 55Here 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 ) { . . . }
- 56How is a GUI component (such as a button) placed into a JFrame?getContentPane().add( Component c )
- 57What letter do many Swing class names start with?J
- 58Can an abstract class define both abstract methods and non-abstract methods?Yes - but the child classes must define the body of abstract methods
- 59What 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.
- 60What is an abstract method?An abstract method is one without a body that is declared with the reserved word abstract.
- 61When 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.
- 62Can an interface ever contain method bodies?No.
- 63A child class can extend ___ parent(s) and can implement ___ interfaces.just one parent; zero or more interfaces
- 64What is an abstract class?a class which cannot be instantiated.
- 65Can an interface name be used as the type of a variable?Yes - the variable can refer to any object whose class implements the interface.
- 66What method is used to read the text from a JTextField?getText()
- 67[T/F] A checked exception is any exception checked for by the compiler.True
- 68____ is when a program is written to respond to button clicks, menu selections, user actionsEvent-driven programming
- 69When the user clicks on a button, what is generated?An event
- 70What is a container object in GUI programming?A container is a GUI component that has other GUI containers placed inside of it.
- 71Which of the following is an exception thrown by the methods of the class String?NullPointerException
- 72In which of the following layout managers do all rows (columns) have the same number of components and all components have the same size?GridLayout
- 73When is a finally{} block executed?Always after the execution of a try block, regardless of whether or not an exception is thrown.
- 74How many finally blocks can there be in a try/catch structure?There can be 0 or 1 following the last catch block.
- 75If the user changes the size of the frame, what happens to the graphical components?The layout manager changes the layout and redistributes the components.
- 76Every try block:must have one or more catch blocks
- 77What 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.
- 78What happens when there is no catch block following the try block?The program will not compile
- 79What is the purpose of the Graphics object?It provides the underlying framework for java graphics operations
- 80What type of object determines where GUI components go in the content pane?The layout manager
- 81Which manager displays components in the possible locations of north, south, east, west, center?BorderLayout
- 82Must a program respond to all events that its components generate?No - it can safely ignore events that don't concern it
- 83Components must be added to the window's ___content pane
- 84Which manager displays components row-by-row, in order in which they were added?FlowLayout
- 85If a negative value is used for an array index, what exception is thrown?IndexOutofBoundsException thrown
- 86What is the name for a method that responds to events?listener method
- 87How does BoxLayout() put components into the content pane?Either top to bottom (vertical), or left to right (horizontal)
- 88The fundamental classes for GUI programming are contained in the:Abstract Windowing Toolkit
- 89Which class of exceptions is NOT checked?RunTimeException
- 90An abstract variable V is a mutable entity that admits two operations:store(V, x), fetch(V)
- 91An implementation detail, such as whether a method is recursive or iterative, should usually be ______ from the user.hidden
- 92A 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
- 93If a recursive algorithm does not make progress toward the base case, it could _____run forever or until the method call stack overflowed.
- 94A 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.
- 95[T/F] A "singleton" design pattern is used to ensure that only ONE instance of a class can be created.true
- 96[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
- 97The operations that modify a stack are:push(), pop()
- 98[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
- 99What are some of the key ACTIVITIES in software development?Definition, Analysis, Design, Implementation, Deployment
- 100A recursive definition is commonly one which defines the nth case in terms of the ______ case.n - 1
- 101An 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
- 102What 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.
- 103What are two ways to view recursion?i. static view; ii. dynamic view
- 104Consider 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
- 105Say that you have an recursive Java method, compute(). Is it always possible to write a iterative version of compute( )?Yes
- 106The FACTORY design pattern's primary purpose is to:create instances of objects
- 107A base case is that part of a recursive definition thatstops the recursion from cycling endlessly.
- 108[T/F] A "singleton" design pattern is used to ensure that only ONE instance of a class can be created.True
Information
- Description
- Review for final in CS 162 for Spring Term, 2014 at Western Oregon State. Questions were taken from quizzes one to five.
- Created by
- jshin13
- Views
- 139
- Tags
- Rating