CIS 199 Final Review.

Slides:



Advertisements
Similar presentations
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Advertisements

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
Fundamentals of Python: From First Programs Through Data Structures
CIS Computer Programming Logic
CIS 199 Test 01 Review. Computer Hardware  Central Processing Unit (CPU)  Brains  Operations performed here  Main Memory (RAM)  Scratchpad  Work.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Introduction to Computer Systems and the Java Programming Language.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Java development environment and Review of Java. Eclipse TM Intergrated Development Environment (IDE) Running Eclipse: Warning: Never check the “Use this.
Applications Development
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6: Transition to Java Programming with Alice and Java First Edition.
CIS 199 Final Review. New Material Structures  Value type  NOT a reference type!  Used to encapsulate small groups of related variables.
CIS 199 Final Review. New Material Classes  Reference type  NOT a value type!  Can only inherit from ONE base class.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Introduction to Object-Oriented Programming Lesson 2.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
CC213 Programming Applications Week #2 2 Control Structures Control structures –control the flow of execution in a program or function. Three basic control.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Chapter 1: Introduction to Computers and Programming
CIS199 Test Review 2 REACH.
Information and Computer Sciences University of Hawaii, Manoa
A variable is a name for a value stored in memory.
Chapter 10 Programming Fundamentals with JavaScript
CIS 199 Test 01 Review.
Topics Introduction Hardware and Software How Computers Store Data
CIS 200 Test 01 Review.
Inheritance and Polymorphism
Java Primer 1: Types, Classes and Operators
C++, OBJECT ORIENTED PROGRAMMING
Chapter 3 Assignment Statement
Computing with C# and the .NET Framework
Programming Language Concepts (CIS 635)
Java Programming: Guided Learning with Early Objects
CIS 199 Test 01 Review.
Chapter 1: Introduction to Computers and Programming
Chapter 10 Programming Fundamentals with JavaScript
Topics Introduction to File Input and Output
Expressions Chapter 4 Copyright © 2008 W. W. Norton & Company.
Java Programming Language
Conditional Statements
Chapter 7 Additional Control Structures
Topics Introduction Hardware and Software How Computers Store Data
CIS 199 Test 02 Review.
PHP.
Structured Program Development in C
Chapter 6: Repetition Statements
Defining Classes and Methods
ICT Gaming Lesson 3.
Focus of the Course Object-Oriented Software Development
2. Second Step for Learning C++ Programming • Data Type • Char • Float
COP 3330 Object-oriented Programming in C++
CIS 199 Final Review.
Defining Classes and Methods
Introduction to Programming
Chap 2. Identifiers, Keywords, and Types
CIS 199 Test 1 Review.
Topics Introduction to File Input and Output
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

CIS 199 Final Review

Classes Reference type Can only inherit from ONE base class NOT a value type! Can only inherit from ONE base class

Properties Class member Holds a piece of data, information within an object Accessors: get, set Can use auto-implemented when validation is not required If need validation, must create own backing field (instance variable) and write own get and set accessors Read-only property – only has get, no set (no public set, at least) Controllable scope

readonly Can make an instance variable readonly Initial value will be established in constructor After value is set, it may not change again

Inheritance Extend, Expand an existing class Specialization Generalization “All students are a person, but not all persons are a student” Derived class “IS-A” base class Student IS-A Person Even if no base class is specified, one will be provided Object This is where method ToString was originally defined

Protected vs Private What is the difference between Protected vs Private?

Protected vs Private Private-The type or member can be accessed only by code in the same class Protected -The type or member can be accessed only by code in the same class, or in a class that is derived from that class.

Polymorphism Complicated Concept An object’s ability to take on, become different forms Child classes take on properties of parent Objects may be treated as base class Students can be treated as a person Keywords of note: “override” – New implementation of a member in a child class that is inherited from base class “virtual” – Class member that may be overridden in a child class “abstract” – Missing or incomplete member implementation. MUST be implemented by child classes // More a 200 concept

Abstract Classes Generic class Provides some members, some information CAN NOT be created directly Meaning direct instantiation is illegal Serves as a common “base” for related objects

Test 01 Material

Computer Hardware Central Processing Unit (CPU) Main Memory (RAM) Brains Operations performed here Main Memory (RAM) Scratchpad Work area for programs, process, temporary data Secondary Storage Hard drive Flash drive CD, DVD

Input, Output Devices Input Output Takes data IN Keyboard, Mouse, Game Controller, Microphone Output Pushes, places data OUT Display, Speakers, Printers

Programs and Digital Data Operating Systems. Microsoft Office, Web browsers Instructions read by CPU and processed Digital Data 1’s 0’s …forms binary (base 2)

Built-In Types

Formatted Output Placeholders Letter codes – C, D, F, P Precision Field width Console.WriteLine(“x = {0,-10:F2}”, x);

Operators ++, -- int x = 5; int y; y = x++; vs y = ++x; Postfix vs Prefix int x = 5; int y; y = x++; vs y = ++x; Shorthand operators +=, -= Integer division 1/2 == 0 1.0 / 2.0 == 0.5 10 / 3 == 3, 10 % 3 == 1 = vs ==

Properties Exposed “Variables” or accessible values of an object Can have access controlled via scope modifiers When thinking of properties: Values and definitions “get” – Code to run before returning a value “set” – Code to run before updating a value Can be used for validation and other processing actions “value” is a keyword in “set”

Methods Actions, code to be executed May return a value, may take value (not required) Can be controlled via scope keywords Can be static // Different example

Scope “private” – Can only be accessed by the class, object itself “protected” – Can only be accessed by the class, object, or any child classes, objects “public” – Available access for all

Named Constants AVOID MAGIC NUMBERS! Allows for reference across similar scope Change once, changes everywhere // ALL CAPS

Conditional Logic if(expression) else if(expression) else If ‘expression’ is true If not true, skipped else if(expression) Can be used to ‘chain’ conditions Code runs if ‘expression’ is true else Code to execute if ‘expression’ false Statements can be nested

Relational Operators > Greater than < Less than >= Greater than OR equal to <= Less than OR equal to == Equal to != NOT equal to X > Y X >= Y X < Y X <= Y X == Y X != Y

Operator Precedence (Highest) ++, --, ! * / % + - < > <= >= == != && || = *= /= %= += -= (Lowest)

Comparing Strings, Chars You can use ==, != You cannot use >, >=, <, <= You SHOULD use: String.Compare(s1, s2) s1 > s2 Returns positive Number s1 = s2 Returns zero s1 < s2 Returns negative number Compares the unicode value of EACH character

Test 02 Material

Basic GUI Example Textboxes, labels, buttons, checkboxes, radiobuttons, panels, groupbox Event handler

Loops for while do – while foreach “For a given value X, while X is true, modify X…” while “While X is true…” do – while “Do these tasks, while X is true…” foreach “For every X in this set of Y do the following…”

for Example

while Example

do while Example

foreach Example

Key Loop Details Loops are NOT guaranteed to execute at least once! …only exception is ‘do while’ Pretest vs posttest, or entry vs exit test ‘for’ loops require a variable, condition, and ‘step’ instruction ‘while’, ‘do while’ loops require a boolean expression ‘foreach’ loops require a collection of items Arrays Indefinite repetition – sequential search, sentinel control, validation loop

Nested loops Output

Methods Actions, code to be executed May return a value, may take value (not required) Can be controlled via scope keywords Can be static

Methods & Modularizing Your Code Break out ‘steps’ Easier to test Easier to visualize Top Down Design

Arrays

Arrays

Sample Questions on Blackboard Wiki

What does ‘WYSIWYG’ stand for? You See Is Get

What is the difference between a high-level and a low-level language? Little to no ‘abstraction’ from the hardware or computer “Close to the hardware” Simple, but Difficult to use Machine code, assembly, C (in some cases) High-Level Very strong ‘abstraction’ from the hardware or computer “Far from the hardware” Easier to use, abstraction adds complexity C++, Java, C#, Python

How is the lifetime of a FIELD different from a lifetime of LOCAL variable? Fields are members of their containing type Fields can be used everywhere with appropriate scope Local variables can be used only in their “local” environment

What two things does a variable declaration specify about a variable? Type Identifier TYPE IDENTIFIER

Describe ‘&&’ and ‘||’ and how they work. Returns true if conditions are ALL true “If you do well on the test AND the quiz, you will earn a great grade!” || (OR) Returns true if ANY conditions are true “You can run a mile OR walk two miles (possible do both!)” Both short circuit

Why is ‘TryParse’ more effective than ‘Parse’? Less code No try / catch required

What is the difference between a SIGNED an UNSIGNED int?

What is the difference between syntax errors and logic errors? Syntax Errors – Errors that prevent compilation or other factors that prevent successful compilation string myString = string.Empty; // Won’t compile, syntax error Logic Errors – Errors that occur during runtime, such as incorrect comparison or other unexpected behavior If(grade > 60) { Code if grade is F } // Incorrect operator used

What are the “Five logical units”? CPU – Processing, instructions Memory – Scratch pad, working space (Temporary) Secondary Storage – Hard drives, storage (Long term) Input – Keyboards, Mice, Controllers Output – Monitors, Speakers, Printers

Explicit type conversion? Why and how? Variables must be used for a single type never change Move from one type to another, must cast EXPLICIT cast / type conversion Aware of information loss

Write a code fragment that will display “Good Job” when int variable score is 80 or more, “OK” when score is 70 – 79, and “Needs Work” for any score under 70.

Write a code fragment that will apply a 10% discount to the value in double variable total when int variable numItems is 5 or more and int variable zone is 1, 3 or 5.

The ‘switch’ statement can replace nested if/else The ‘switch’ statement can replace nested if/else. But under what conditions? When matching on a specific… Value Type Enumeration …other data Doesn’t work for floating point types

What does a ‘break’ statement do in a loop? It stops (BREAKS) loop execution Code continues, no further loop iterations Example: switch (comboBox1.SelectedItem.ToString()) { case "A": class_one_textBox = int.Parse(textBox1.Text); grade = 4.00 * class_one_textBox; break; case "A-": class_one_textBox =int.Parse(textBox1.Text); grade = 3.67 * class_one_textBox;

What does a ‘continue’ statement do in a loop? Goes to the next iteration CONTINUES loop execution, by skipping current iteration This is only time a for loop would behave differently than a while loop

What are preconditions and postconditions for a method? Conditions that MUST be TRUE before method execution POSTCONDITIONS Conditions that WILL be TRUE after method execution

What is the difference between a void method and a value-returning method? Returns nothing! …a void return. Value-Returning Returns a value! …that’s not a void return.

Compare and contrast the use of pass by value against pass by reference, using key word ref versus pass by reference using keyword out. Pass by Value Passes a copy of the value Not the object itself Pass by Reference Passes the actual object itself ‘ref’ Causes a pass by reference on a variable ‘out’ Is used to reference a variable that the method will update

How can REACH further help you today? Ask Questions Now! Need to see an Example? Need to see a concept again? Visit https://reach.louisville.edu/examprep/CIS-TestReviews.html