








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 concepts in computer science, focusing on java programming. It covers topics such as buffered input, wrapper classes, string tokenizers, scanner classes, variable declarations, control structures (selection and loops), methods, and object-oriented programming principles. Explanations and definitions of key terms and concepts, making it a useful resource for students learning java. It also includes questions and answers related to the topics covered, enhancing its educational value. Useful for university students.
Typology: Exams
1 / 14
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
Two way selection - Answer -Regardless of conditions, one of two paths (blocks of code) are taken. Both paths then converge on the same line of code. Multi way selection - Answer -Mulitple paths exist that can be taken depending on the conditional tests Decision tree - Answer -Decision tree structure are nested multi way selection structures Left decision tree - Answer -Decisions are checked on true conditions and the if statemnt is nested in the following if statement Right decision tree - Answer -Also known as the standard tree, the conditions are checked until the first TRUE condition is encountered Switches - Answer -Are used when you have an integer comparison. THe switch control takes the place of the if else statements. Conditions for switch - Answer -1. A comparison is being performed
argument method) 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
Class = data + methods Components of an OOP class - Answer -class name Class member declaration Constructors (kind of method) Methods Class members - Answer -Constructors, methods, and variables Variable members - Answer -Also referred to as data members or instance variables Data operations - Answer -Data operations can only be executed using class members Public vs private - Answer -Normally the data members are declared as private and the methods as public Constructors - Answer -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 - Answer -The section of a program within which an identifier is valid or known Block scope - Answer -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 - 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
Computer Program? - Answer -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 - Answer -An algorithm is a programming recipe. Recommendations for algorithm selection - Answer -1. Avoid algorithms which cause informal problems.
class name. No object name is used. Wrapper Classes - Answer -Wrapper classes allow us to convert between different variable types: strings, integers, doubles, booleans, etc String Tokenization - Answer -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 - Answer -The process of tokenization Primitive vs Reference Data Types - Answer -Primitive data types can perform simple arithmetic. Reference data types require methods to be manipulated. String? - Answer -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 - 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
The allocation is not done until the object is instantiated. Therefore string msg; does nothing. Logical Operators - Answer -OR NOR XOR XNOR AND NAND NOT Use of Logical Operators - Answer -1. For Supporting multiple or complex conditions
integer compatibles (characters) Switches must use "breaks" to avoid code "fall through" When to use switch control - Answer -1. When a comparison (equality) is performed
Difference between a file and an array - Answer -A file persists beyond the program that interacts with it. It uses SECONDARY storage. Files also have ATTRIBUTES and POINTERS. An array is just a COLLECTION OF BYTES and exists in PRIMARY storage. The array only exists as long as the program or method that calls it Two steps for declaring an array - Answer -Declaring the reference variable Creating the array object and defining length The first statement DECLARES THE DATA TYPE of the items that will be stored in the array, as well as the array name. The second statement FORCES THE PROGRAM TO CREATE AN ARRAY OBJECT. The array is created to contain the designated number of locations and STORES THE LOCATION of this ARRAY OBJECT INTO THE REFERENCE VARIABLE. Array initialization - Answer -The array elements can be read by using inputStream classes and Java GUI options. They can also be assigned during initialization of the array