















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















Buffered Input - SOLUTION -Provides a way to create interactive computer programs with input form the user through the keyboard and or mouse, which can be processed and output by the program. InputStreamReader - SOLUTION -converts the integer values of the System.in to its character representation BufferedReader - SOLUTION -constructs a string from the character values provided by InputStreamReader Wrapper classes - SOLUTION -Wrapper classes convert form String (a reference data type) to primitive data types and vice-versa StringTokenizer - SOLUTION -The String Tokenizer class is used to break a large chunk of infomration into smaller, useful toekns. The process of breaking a string down into tokens is called parsing Scanner class - SOLUTION -The Scanner provides a broad range of options for data entry and parsing. It essentially consolidates the functionality of buffered input, wrapper classes, and the StringTokenizer class 2 Steps of Primitive Variable declaration - SOLUTION -1. Allocates memory for the variable - Declaration
3 parts of Methods - SOLUTION -Calling statements Heading Method body Calling a method - SOLUTION -A general purpose is called by giving hte method's name and passing parameters to it. Functions of main method - SOLUTION -1. constructs objects
The caller can use the values directly in the expression, system statement, or it must have allocated storage to hold the returned values Static methods - SOLUTION -Static methods receive all of their information from the arguments. Static methods are usually public and are called general methods. In order to reference them, they do not have to be prefaced by the class name Strict methods - SOLUTION -Strict methods operate on objects and are identified by the object they act on and their class Objects and Classes - SOLUTION -In object oriented languages, all data types are constructed as classes, and all data values are objects Class characteristics - SOLUTION -A class is a programmer defined data type, a combination of data, and their associated operations Class = allowable data + operation capabilities OR Class = data + methods Components of an OOP class - SOLUTION -class name Class member declaration Constructors (kind of method) Methods Class members - SOLUTION -Constructors, methods, and variables Variable members - SOLUTION -Also referred to as data members or instance variables
Data operations - SOLUTION -Data operations can only be executed using class members Public vs private - SOLUTION -Normally the data members are declared as private and the methods as public Constructors - SOLUTION -A method that has the same name as the class and no return statement. Used to initialize the variables. A class can have one or more constructors. Multiple constructors are ok as long as they have different signatures (number and type of parameters) Scope - SOLUTION -The section of a program within which an identifier is valid or known Block scope - SOLUTION -Variables and parameters with block scope can be used from their point of declaration until the end of their block code. Local variables take precedence over the class variable with the same name Class scope - SOLUTION -These variables and parameters are available throughout all modules of a class. Class variables can be accessed by using the class name in the statement. The variables declared in outer blocks can be accessed within all inner blocks. The variables in outer blocks are static. Variables declared within inner blocks cannot be accessed in any enclosing outer blocks. The variables within a block go out of scope after the block end } Computer Science - SOLUTION -The study of how computers can be applied effectively and efficiently to solve problems.
Problem of Synthesis - SOLUTION -A formal problem where the initial condition (input) and the plan of action are known. The goal is to identify the result (output). Problems of Synthesis are generally solved by a computer. Real Formal Problems - SOLUTION -Real formal problems - The making of a product Artificial Formal Problems - SOLUTION -Simulated problem (playing games/AI). Problems of Analysis and Synthesis - SOLUTION -Generally speaking software engineers convert problems of analysis to problems of synthesis which can then be solved by computers. Plan of Action - SOLUTION -A general outline of the major steps we need to accomplish our goal, starting at predefined initial conditions. Algorithm - SOLUTION -Algorithm is a set of defined instructions which result into a solution Problem Theory - SOLUTION -The study of characteristics of problems. Most problems have certain characteristics that are independent of the details of any particular problem or may have a relation to other problems in general. Algorithm as it Relates to Problem Theory - SOLUTION -Algorithms can be defined as a refinement of a plan of action. Computer Program? - SOLUTION -A computer program is the statement of an algorithm in a computer programming language.
It is a collection of instructions that a computer can understand, process and accomplish. It is an exacting task. Algorithm - SOLUTION -An algorithm is a programming recipe. Recommendations for algorithm selection - SOLUTION -1. Avoid algorithms which cause informal problems.
Purpose of OOP - SOLUTION -To provide software developers with: Reliability Cost effectiveness Adaptability Understandability Reusable Object - SOLUTION -All objects have:
Object Oriented Programs - SOLUTION -Complex software programs requiring proper abstraction and separating the internal implementation from external behavior of the object. Characteristics of OOP - SOLUTION -Polymorphism Inheritance Encapsulation Polymorphism - SOLUTION -The capability of an object to assume different forms. Messages can lead to different operations depending on the object receiving it. Example: Context based right clicking Polymorphism - SOLUTION -The mechanism by which one general interface can be used to access different specific implementations. Inheritance - SOLUTION -Each object is related to one or more objects. One class of objects inherits data behavior from another object. In other words, sub classes share characteristics of the class they are derived from. Encapsulation - SOLUTION -The mechanism that binds together codes and data and prevents unauthorized access to the heart of the class which is private. A class is designed such that the implementation is protected from the action of external code except through form interface. Module - SOLUTION -A structure consisting of interrelated segments arranged in logical order to form an integrated unit. It is constructed basically from classes.
Wrapper Classes - SOLUTION -Wrapper classes allow us to convert between different variable types: strings, integers, doubles, booleans, etc String Tokenization - SOLUTION -Using ReadLine(), it is possible to convert a string of multiple items into individual values (tokens). _______ _______ generally requires wrapper classes to convert between different integer types Parsing - SOLUTION -The process of tokenization Primitive vs Reference Data Types - SOLUTION -Primitive data types can perform simple arithmetic. Reference data types require methods to be manipulated. String? - SOLUTION -A string is a REFERENCE data type where the variable references the location in memory where the actual value is stored. The actual stored value is the object. Instantiation - SOLUTION -The process of allocation that creates a SPECIFIC instance of an object Two data types that don't have to be instantiated - SOLUTION - Strings and arrays two ways to declare the string msg = "foo" - SOLUTION -String msg = new String ("foo"); //with instantiation String msg = "foo"; //without instantiation Automatic Dereferencing - SOLUTION -The process of obtaining the address from a reference variable and going to the address to retrieve the correct number of bytes for the object.
handle dangling pointers caused by string literals - SOLUTION -How does Java handle dangling pointers caused by string literals declared without instantiation? Java periodically runs a GarbageCollection method to eliminate objects with zero reference. when a Primitive Data Type is declared? - SOLUTION -1. A space is reserved for an int data type
two types of control structures - SOLUTION -Selection Control Structure and Loop Control Structure Selection Control Structure - SOLUTION -Allows the program to execute one of the alternative paths. The selection is governed by the outcome of a conditional test that evaluates if a statement is true or false. Three types of selection control structures? - SOLUTION -One-way selection control structure, two-way selection control structure, and multi-way selection control structure. one way selection control - SOLUTION -which way? The conditional path is selected if the condition is true. If false, the corresponding statement(s) will be passed and the lines of code following the block are executed. Two-way selection control - SOLUTION -Regardless of conditions, one of two paths will always be taken Multi-way Selection Control - SOLUTION -Selection control that involves more than two structures. Two types of multi-way selection control - SOLUTION -Nested selection control and switch control structure Nested Control structure - SOLUTION -Multiple number of "IF" statements are nested during a process. There are two forms of nested control structure, left-decision tree and right-decision tree left-decision tree nested control - SOLUTION -the "IF"s are nested in the "IF" structures not in the else block structure. This decision
tree control structure is not commonly used. The syntax is as follows: IF (cond1) IF (cond2) Statement 1 ELSE Statement 2 ELSE Statement 3 Right decision tree - SOLUTION -in this nested control structure, the statements are tested until a true statement is found. This is the most common nested control structure. The syntax follows: IF (cond1) Statement 1 ELSE IF (cond2) Statement 2 ELSE IF (cond3) Statement 3 ELSE Statement 4 Switch Control - SOLUTION -The switch statement allows you to choose from a fixed set of alternatives. It is used in a narrow collection of situations. Switches should not be used with real numbers. only Integers and integer compatibles (characters) Switches must use "breaks" to avoid code "fall through" When to use switch control - SOLUTION -1. When a comparison (equality) is performed