CSCE 111 Final Exam Terms

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The int data type may contain values in the following range of values

- 2,147,483,648 to +2,147,483,647

Abstract Classes

- cannot be instantiated, but other classes are derived from it. - serves as a superclass for other classes. - represents the generic or abstract form of all the classes that are derived from it. A class becomes abstract when you place the abstract key word in the class definition. public abstract class ClassName

Abstract Methods

- no body and must be overridden in a subclass. - appears in a superclass, but expects to be overridden in a subclass. - has only a header and no body. AccessSpecifier abstract ReturnType MethodName(ParameterList);

What is the value of a? double a = 25 / 4 + 4 * 10 % 3;

7.0

Java provide...primitive data types.

8

protected

A protected member's access is somewhere between private and public. any class that is derived from the class, or is in the same package, has unrestricted access to the protected member

Overriding Superclass Methods

A subclass may have a method with the same signature as a superclass method. The subclass method overrides the superclass method. method overriding

Each repetition of a loop is known as what?

An iteration

classes and objects

An object is an instance of a class. The state of an object is represented by data fields and the behavior of an object is defined by a set of methods.

When does array bounds checking occur?

At run time

Calling The Superclass Constructor

If a parameterized constructor is defined in the superclass, the superclass must provide a no-arg constructor or subclasses must provide a constructor, and subclasses must call a superclass constructor. Calls to a superclass constructor must be the first java statement in the subclass constructors.

Instances

Instances and objects are used interchangeably. Creating an instance is referred to as instantiation. You can access an instance variable or invoke an instance method only on a specific instance. You can create many instances of a class

Interfaces

It cannot be instantiated, and all of the methods listed in an interface must be written elsewhere. The purpose of an interface is to specify behavior for other classes. - replaces the word class

Static Methods

It is not necessary for an instance of the class to be created to execute the method. They are created by placing the key word static after the access specifier in the method header. They can access all other static methods and fields defined in the class They are often used to create utility classes that perform operations on data, but have no need to collect and store data.

The following statement creates an ArrayList object. What is the purpose of the <File> notation? ArrayList<File> arr = new ArrayList<File>();

It specifies that only File objects may be stored in the ArrayList object.

Wrapper Classes

Java provides wrapper classes for all of the primitive data types. A wrapper class is a class that is "wrapped around" a primitive data type. The wrapper classes are part of java.lang so to use them, there is no import statement required.

The keyword "this":

Refers to the object thru which the method was called

concat

Returns a String object that is the concatenation of two String objects.

trim

Returns a String object with all leading and trailing whitespace characters removed.

replace

Returns a String object with all occurrences of one character being replaced by another character.

toCharArray

Returns the String object's contents in an array of char values.

boolean isDigit( char ch)

Returns true if the argument passed into ch is a digit from 0 through 9. Otherwise returns false.

If you have defined a class SmartPhone with a public static method assignNetwork(), and a client created a SmartPhone object referenced by the variable iphone, what will call the assignNetwork()method from the client class?

SmartPhone.assignNetwork();

static variables, methods and constants

Static variables from a class are designed to be shared by all the objects of the class. Static methods are not tied to a specific object. A class can have multiple static variables. Declaration of static constants has the static modifier.

getChars

Stores a substring in a char array

You can use this method to determine whether a file exists

The File class's exists method

delimiter

The character that separates tokens

Preventing a Method from Being Overridden

The final modifier will prevent the overriding of a superclass method in a subclass. If a subclass attempts to override a final method, the compiler generates an error.

Where does the interpreter begin execution?

The main method

The Character class allows...

a char data type to be wrapped in an object.

If a subclass fails to override an abstract method...

a compiler

If a subclass fails to override an abstract method...

a compiler error will result

Tokens

a series of words or other items of data separated by spaces or other characters. "peach raspberry strawberry vanilla" This string contains the following four tokens: peach, raspberry, strawberry, and vanilla.

After the append method is called...

a string representation of item will be appended to object's contents. StringBuilder str = new StringBuilder(); str.append("We sold "); str.append(12); str.append(" doughnuts for $"); str.append(15.95);

Sentinel

a value that signals when the end of a list of values has been reached.

Java performs dynamic binding or late binding when...

a variable contains a polymorphic reference.

When an object, such as a String, is passed as an argument, it is...

actually a reference to the object that is passed

A specialized object has...

all of the characteristics of the general object, plus additional characteristics that make it special.

The keyword 'new':

allocates memory for the object

The import statement :

allows programs to access classes that are already defined elsewhere

A double can be forced into a float by

appending the letter F or f to the literal. float number; number = 23.5F; // This will work.

Values stored in local variables

are lost between calls to the method in which they are declared

Infinite loops:

are not detected by the compiler are always bugs in the program

Members of the superclass that are marked private

are not inherited by the subclass, exist in memory when the object of the subclass is created. may only be accessed from the subclass by public methods of the superclass.

Any class that contains an abstract method is...

automatically abstract

This type of loop is ideal in situations where the exact number of iterations is known

for

A StringBuilder object will...

grow or shrink in size, as needed, to accommodate the changes.

String objects are

immutable, meaning that they cannot be changed.

Wrapper classes are...

immutable, which means that once you create an object, you cannot change the object's value.

A deep copy of an object:

is an operation that copies an object, and all the objects it references

Any class that does not specify the extends keyword...

is automatically derived from the Object class. public class MyClass { // This class is derived from Object. }

inheritance

is used to create an "is a" relationship among classes. -Overriding can only take place in an inheritance relationship. involves a superclass and a subclass.

a reference variable is polymorphic because...

it can reference objects of types different from its own, as long as those types are subclasses of its type.

When an argument is passed to a method

it is represented by the parameter variable in the method definition

super

keyword that allows a subclass method to call the overridden superclass method

Local variables

lose the values stored in them between calls to the method in which the variable is declared are only meant for use in the method they are declared

Overloading

multiple methods in the same class have the same name, but different parameter lists

The do-while loop

post-test loop, which means it will execute the loop prior to testing the condition.

The for loop is a

pre-test loop

In the Java programming language, an argument is used to...

provide values to an invoked method

The String class

provides several methods that search for a string inside of a string.

When an array is passed to a method:

reference to the array is passed it is passed just as an object the method has direct access to the original array

ragged array

refers to a two dimension array with different sizes for one of the dimensions

A subclass method that overrides a superclass method must have the...

same signature as the superclass method.

Which of the following values can be passed to a method that has an int parameter variable?

short, and int

Wrapper classes provide...

static methods that are very useful

substring

string that is part of another string. Some of the substring searching methods provided by the String class:

In order to do a binary search on an array...

the array must first be sorted

The scope of a private instance field is:

the instance methods of the same class

When two String variables a and b are compared using "==":

the memory addresses of a and b are compared to see if they are the same

A parameter variable's scope is...

the method in which the parameter is declared

a method's signature consists of:

the method's name the data types method's parameters in the order that they appear.

The phrase divide and conquer is sometimes used to describe

the process of breaking a problem down into smaller pieces

Input validation

the process of inspecting data given to the program by the user and determining if it is valid.

If you attempt to perform an operation with a null reference variable:

the program will terminate with an exception

The Character class provides...

two methods that will change the case of a character.

extends

used on the class header to define the subclass. public class FinalExam extends GradedActivity

The startsWith method determines...

whether a string begins with a specified substring. String str = "Four score and seven years ago"; if (str.startsWith("Four")) System.out.println("The string starts with Four."); else System.out.println("The string does not start with Four.");

Which of the following are pre-test loops?

while, for

f a loop is nested, the inner loop will...

execute all of its iterations for each time the outer loop executes once.

Inheritance and Constructors

Constructors are not inherited. When a subclass is instantiated, the superclass default constructor is executed first.

The StringTokenizer class provides:

CountTokens - Count the remaining tokens in the string. hasMoreTokens - Are there any more tokens to extract? nextToken - Returns the next token in the string. - Throws a NoSuchElementException if there are no more tokens in the string.

tokenizing

The process of breaking a string into tokens

StringBuilder()

This constructor gives the object enough storage space to hold 16 characters.

Superclasses are also called...

base classes

The StringTokenizer class

breaks a string down into its components, which are called tokens.

Any method that calls a method with a throws clause in its header must...

catch and handle the potential exception or have the same throws clause

In memory, an array of String objects

consists of elements, each of which is a reference to a String object.

Local variables can be initialized with

constants, parameter values, the results of an arithmetic operation

If method A calls method B, and method B calls method C, and method C calls method A, when the last call to method A finishes, what happens?

control is returned to method C

A loop that repeats a specific number of times is known as a(n)

counter-controlled loop

The subclass inherits...

fields and methods from the superclass without any of them being rewritten. all non private attributes and methods

subclasses are also called...

derived classes

Given the following statement, which statement will write "CS111" to the file DiskFile.txt? PrintWriter diskOut = new PrintWriter("DiskFile.txt");

diskOut.println("CS111");

the Object class:

every class inherits the Object class's members. example: toString and equals. In the Object class, the toString method returns a string containing the object's class name and a hash of its memory address.

The sequential search algorithm:

examines each array element for a match


संबंधित स्टडी सेट्स

Assignment 9 - Underwriting Umbrella and Excess Liablity Insurance

View Set

Pediatrics Dev't and Health Promotion Ch. 3-5 Prep U & Ati 3-7

View Set

Mr. Fair CP Religion - Scripture Unit 3 Study Guide

View Set

Intermediate accounting 1 exam 4

View Set

Income taxation- CHAP 1 Basic Principles

View Set

AP Psychology: Unit 4 Practice Test

View Set