CSC 201 Final Exam Q&A: Computer Science Fundamentals, Exams of Computer Science

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

2024/2025

Available from 06/06/2025

Nursmerrit
Nursmerrit šŸ‡¬šŸ‡§

5

(1)

3.4K documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSC 201 Final Exam Question and
Answers Latest Update 2025
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
2. Association of variable name with meory location (initialization)
3 steps of Reference variable declaration - Answer-1. A list of all
variable objects and the associated data types is provided to the
compiler
2. Allocation of sufficient memory for hte declared type
3. once the object is instantiated, the first byte of the address is
associated with the variable name
Control structures - Answer-A segment of a program that takes
control of the program. Control structures have one point of entry
and one point of exit in the program.
Logical or boolean operators - Answer-Logical operators evaluate
logical conditions. Often used in control structures, they return
one of two values - false or true
Selection controlled structure - Answer-Selection control
structures use conditional tests to change the path of a program.
Rather htan follow the program from one statemtn to the next,
statements can be skipped and new paths selected
One way selection - Answer-The conditional path is selected if
the condition is true. If false, the corresponding statements will be
skipepd and the liens of code following the block will be executed
instead.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download CSC 201 Final Exam Q&A: Computer Science Fundamentals and more Exams Computer Science in PDF only on Docsity!

CSC 201 Final Exam Question and

Answers Latest Update 2025

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

  1. Association of variable name with meory location (initialization) 3 steps of Reference variable declaration - Answer -1. A list of all variable objects and the associated data types is provided to the compiler
  2. Allocation of sufficient memory for hte declared type
  3. once the object is instantiated, the first byte of the address is associated with the variable name Control structures - Answer -A segment of a program that takes control of the program. Control structures have one point of entry and one point of exit in the program. Logical or boolean operators - Answer -Logical operators evaluate logical conditions. Often used in control structures, they return one of two values - false or true Selection controlled structure - Answer -Selection control structures use conditional tests to change the path of a program. Rather htan follow the program from one statemtn to the next, statements can be skipped and new paths selected One way selection - Answer -The conditional path is selected if the condition is true. If false, the corresponding statements will be skipepd and the liens of code following the block will be executed instead.

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

  1. One expression is bieng compared in each fo the conditions
  2. The type of value to which the expression is being compared is integer compatible 6 types of loops - Answer -1. Counter controleld structure (for loop)
  3. Event controlled strucutre (while) 3 Sentinel conotrolled strucutre (while)
  4. Flag controlled structure (while)
  5. Pre-test loop (z trip)
  6. Post test loop (1 trip) - (do while) Counter controlled loop - Answer -(for loop). The loop is fixed by the counter. tHe process is repeated regardless of other conditions (exceptions exist). The lopp is exectuted a known number of times. 4 steps of counter controlled loop - Answer -1. Initialization of Loop controlled variable (LCV)
  7. Loop condition - tests value of LCV
  8. Loop body
  9. Update the LCV Symmetrical bound counter - Answer -<= in the loop condition Means the count = (b-a) + 1 Asymmetrical bound counter - Answer -< in the loop condition means the count = (b-a)

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

OR

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.

  1. Avoid algorithms with undetermined solutions
  2. Avoid algorithms which require excessive amounts of time.
  3. Select algorithms that closely fit the specifications
  4. Select algorithms which allow for assumptions
  5. Select algorithms which don't generate multiple problems 6.1 Examine the algorithm's efficiency Four Stages of Program Development - Answer -1. Program Planning
  6. Program Coding
  7. Testing and Debugging
  8. Maintenance/Refactoring Three Principles of Programming Style - Answer -1. Program structure and design
  9. Program Documentation
  10. Program Overall Appearance and Style Program design structures - Answer -Top Down and Bottom Up Bottom up design - Answer -Modules are designed first, then put together to form the main program. Advantage of Bottom up design - Answer -Less expensive and faster to build Disadvantage of Bottom up design - Answer -Reason: The pieces don't always work well together. 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
  11. Functioning of each unit
  12. Summary of the problem specification
  13. Special algorithms (if used)
  1. Assumptions made
  2. Formulation
  3. Name of program
  4. Date
  5. Date of last modification
  6. Project Name
  7. Division/Dpt
  8. References used for program development Suggestions for Program Appearance - Answer -1. Format the program in a way that enhances its readability
  9. Use spaces between segments
  10. All composite sequences must be separated
  11. Use appropriate (and well named) identifiers Purpose of OOP - Answer -To provide software developers with: Reliability Cost effectiveness Adaptability Understandability Reusable Object - Answer -All objects have:
  12. Name
  13. Behavior
  14. Receives input (receives message) Example: Remote Control - Answer -name - remote control behavior - changes channels on a television receives input - from user using the number/keypad Stages of Program Design - Answer -stages
  15. Input Phase
  16. Output Phase
  17. Formulation of Assumptions
  18. Constraints Input phase of Program Design - Answer -Identify where input comes from and what they are. User? Storage? Output phase of Program Design - Answer -Identify the outputs of the computer program. Does something get displayed on the screen? On a printer? 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

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

  1. The variable name gets associated with the first byte of allocated storage Reference Data Type is declared - Answer -reference data type
  2. A list of all variable objects and their associated data types are generated for compiling.
  3. Sufficient memory is allocated for the declared type as referenced by the address.
  4. The first byte of the address is assigned to the reference name, only after the object is instantiated.

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

  1. For setting or clearing bit sequences OR - Answer -True when any input is true. The java syntax is || Used for bit setting (sets any or all bits to 1) in a sequence. AND - Answer -True when all conditions are true. The java syntax is &&. Used for filtering/masking a bit pattern. Allow only the 1st and 2nd bits through: 10101101 00000011 00000001 XOR - Answer -Also called the equivalence operator. Returns FALSE when both statements are the same. The Java syntax is a compound statement (!ab + a!b). Used for testing bit sequence errors (unexpected state change) and also for flipping: 10101101 11111111 01010010 NOT - Answer -The NOT operator is used to reverse a condition. Java Syntax is !. Shift operator - Answer -Used to shift bit patterns to the right or to the left. Logical shifts multiply or divide the pattern by the pattern's base. (LogicalShiftLeft x) (LogicalShiftRight /) Relational Operators - Answer -An operator which determines the relationship of a one value to another and returns a true or false result. They are binary operators != >= <= > < == Control Structure - Answer -(general) A group of individual instructions in a program that takes control of the program. The control structure should have only one entry and one exit point. two types of control structures - Answer -Selection Control Structure and Loop Control Structure Selection Control Structure - Answer -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

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

  1. When the same expression is being compared in each condition
  2. When the type of value to which the expression being compared is integer compatible Scalar data type - Answer -Simple data such as int a = 25; Composite Data type - Answer -Structured or unstructured Structured data type - Answer -made up of an ORGANIZED COLLECTION OF COMPONENTS of same or other types. Structure data types are organized such that THEIR COMPONENTS CAN BE ACCESSED INDIVIDUALLY. Unstructured - Answer -The values of this data type are not organized with repect to one another. THE ONLY RELATIONSHIP THAT THESE VALUES HAVE IS THAT OF BEING MEMBERS OF THE SAME GROUP. The values CANNOT BE ACCESSED INDIVIDUALLY. The values are only determined by the group that they belong to Constructor methods - Answer -- SAME TYPE AS THE CLASS
  • NO RETURN type
  • Multiple constructors are acceptable
  • A constructor method is REQUIRED. If one is not explicitly in the program, Java will create one automatically.
  • The primary function of the constructor method is to INITIALIZE VALUES Key difference from other types of methods - Answer - Differences:
  • Regular methods are called by name.
  • Constructor methods are called automatically when objects are instantiated. Overloading constructor methods - Answer -Multiple constructor methods are often included in programs to allow you to declare objects in different ways. This is acceptable as long as the constructors have DIFFERENT PARAMETER SIGNATURES (different quantity/types of parameters) Array - Answer -a HOMOGENEOUS, INDEXED, COMPOSITE DATA STRUCTURE used to store ELEMENTS of one data type. It is the fundamental mechanism in Java for collecting multiple values Array components - Answer -The elements of the ____ the indices that locate the stored elements

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