


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive overview of fundamental computer science concepts, including input/output, data types, control structures, and methods. It explains key programming concepts like buffered input, wrapper classes, and the scanner class, along with detailed explanations of different types of loops and methods. Particularly useful for beginners in computer science, offering clear explanations and examples.
Typology: Exams
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















Buffered Input - Answer -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 - Answer -converts the integer values of the System.in to its character representation BufferedReader - Answer -constructs a string from the character values provided by InputStreamReader Wrapper classes - Answer -Wrapper classes convert form String (a reference data type) to primitive data types and vice-versa StringTokenizer - Answer -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 - Answer -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 - Answer -1. Allocates memory for the variable - Declaration
Sentinel controlled loop - Answer -Uses an artificial data (ADV) value within a data set to tirgger the end of a control loop. For example, a program may not need a negative value. The writer of the program can then use a negative number as the sentinel value. As long as the user doesn't enter a negative number ,the loop will continue to be processed. Flag controlled loop - Answer -A boolean statement is used to control the flow of the program. For example: in a situation where all nubmers are valid (postiive, negative, or zero) you must rely on a logical statement to exit the loop. For example, if the next input is not a floating pointn umber, then the condition is false and exits the loop Pre test loop - Answer -(z trip) Test is prior to the code block. This means it's possible the code block will never get executed. Post test loop - Answer -(1 trip) - test happens after the code block. This means the code block gets executed at least once. 3 parts of Methods - Answer -Calling statements Heading Method body Calling a method - Answer -A general purpose is called by giving hte method's name and passing parameters to it.
Method signature - Answer -The number, type, and order of parameters determines the method's signature. Every method has one Actual parameters - Answer -The parameters in the calling statment, also known as arguments. Memory locations are allocated prior to the call. They exist as long as the program is active and running. Formal parameters - Answer -Also known as parameter variables, these variables are created for recieving the method's arguments (actual parameters). As soon as the values are returned and the control is transferred back to the caller, all of the values are discareded and the allocated memory location will be released. Teh method itself considers only the formal parameters (those declared inteh method header) and has no knowledge of the actual parameters (in the calling statement) Passing by value - Answer -Arguments passed as primitive data types. A copy of the value is made and stored in a varialbe which is passed to the called method Value parameters are NOT affected by changes made within a method. Passing by reference - Answer -the reference variable in the main program references a different variable. The parameters in called method will refer to different objects Handling return statements - Answer -When a return statement is encountered, the expression is evaluated first
and its value is returned to the calling method. After the value is returne,d the control is transferred back to the caller. All local variables and formal parameters are then discarded. 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 - Answer -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 - Answer -Strict methods operate on objects and are identified by the object they act on and their class Objects and Classes - Answer -In object oriented languages, all data types are constructed as classes, and all data values are objects Class characteristics - Answer -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 - Answer -class name
Class scope - Answer -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 - Answer -The study of how computers can be applied effectively and efficiently to solve problems. Fields of Computer Science - Answer -Switching Theory Software Engineering Automation and Control Robotics Biotechnology Hardware Design Problem? - Answer -A goal or a task. The difference between actual conditions and those that are required or desired. Components of a Problem - Answer -components of? Initial conditions => Problem => Result input => Plan of Action => Outcome
Informal Problems - Answer -Informal problems have no satisfactory solution. The result of the problem cannot be achieved knowing the specifications of the problem (initial conditions and the plan of action). There is no satisfactory solution. Formal Problems - Answer -Characterized by complete specification of a problem: initial conditions, plan of action, and expected outcome. Two Categories of Formal Problems - Answer -Problems of analysis and problems of synthesis Problem of Analysis - Answer -A formal problem where the initial condition (input) and the result (output) are known. The goal is to identify the plan of action. Problems of Analysis are generally solved by a programmer or software engineer Problem of Synthesis - Answer -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 - Answer -Real formal problems - The making of a product Artificial Formal Problems - Answer -Simulated problem (playing games/AI).
Top Down design - Answer -The overall structure of the program is already known and modules are integrated as design progresses. Disadvantage of Top Down design - Answer -Expensive and time consuming Advantage of Top Down design structure - Answer - Reason: Highly customized. Elements of program Documentation - Answer -1. Explanation of components
Abstract data type - Answer -Refers to a data type together with a set of operations that can be performed on that data structure. Object Oriented Programs - Answer -Complex software programs requiring proper abstraction and separating the internal implementation from external behavior of the object. Characteristics of OOP - Answer -Polymorphism Inheritance Encapsulation Polymorphism - Answer -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 - Answer -The mechanism by which one general interface can be used to access different specific implementations. Inheritance - Answer -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 - Answer -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 - Answer -A structure consisting of interrelated segments arranged in logical order to form an integrated unit. It is constructed basically from classes. Class - Answer -Consists of a Data Structure and methods that can be applied to that structure. A class is a module unit. Class = operations + data structure Methods - Answer -A unit of a program module that contains a sequence of operations and statements. In Java, methods can ONLY exist within a class. two types of Java methods - Answer -Strict (Instance) methods Static methods Strict method format - Answer -format - The method is associated with an object and use the instance variables of that object. Instance methods are called by prefixing it with an object. Example: System.out.println("") also known as instance methods Static method format - Answer -format - Static methods are called by prefixing them with the class name. No instance variables of any object of the class are defined in the method. Example: Math.pow(2,3) calls the exponent method pow.
Instantiation - Answer -The process of allocation that creates a SPECIFIC instance of an object Two data types that don't have to be instantiated - Answer -Strings and arrays two ways to declare the string msg = "foo" - Answer - String msg = new String ("foo"); //with instantiation String msg = "foo"; //without instantiation Automatic Dereferencing - Answer -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 - Answer -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? - Answer -1. A space is reserved for an int data type