CIS 199 Final Review. New Material Structures  Value type  NOT a reference type!  Used to encapsulate small groups of related variables.

Slides:



Advertisements
Similar presentations
Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.
Advertisements

Introduction to Programming Lesson 1. Objectives Skills/ConceptsMTA Exam Objectives Understanding Computer Programming Understand computer storage and.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 11: Classes and Data Abstraction
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Programming Languages and Paradigms Object-Oriented Programming.
Topics Introduction Hardware and Software How Computers Store Data
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 © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
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.
The Java Programming Language
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
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.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
Page: 1 การโปรแกรมเชิงวัตถุด้วยภาษา JAVA บุรินทร์ รุจจนพันธุ์.. ปรับปรุง 15 มิถุนายน 2552 Keyword & Data Type มหาวิทยาลัยเนชั่น.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CIS 199 Final Review. New Material Classes  Reference type  NOT a value type!  Can only inherit from ONE base class.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
 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.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 12: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
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.
Controlling Program Flow with Decision Structures.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
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 –
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Introduction to Programming Lesson 1. Algorithms Algorithm refers to a method for solving problems. Common techniques for representing an algorithms:
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming
Information and Computer Sciences University of Hawaii, Manoa
CIS 199 Test 01 Review.
CIS 200 Test 01 Review.
CIS 199 Test 01 Review.
Java Programming Language
Conditional Statements
CIS 199 Test 02 Review.
Focus of the Course Object-Oriented Software Development
CIS 199 Final Review.
CIS 199 Final Review.
Introduction to Programming
CIS 199 Test 1 Review.
Presentation transcript:

CIS 199 Final Review

New Material

Structures  Value type  NOT a reference type!  Used to encapsulate small groups of related variables

Classes  Reference type  NOT a value type!  Like a structure, but far more sophisticated, modern  Can only inherit from ONE base class  Can inherit from MANY interfaces

Properties  Class member  Holds a piece of data, information within an object  Accessors: get, set,  Controllable scope

Inheritance  Extend, Expand an existing class  Specialization  Generalization  “All students are a person, but not all persons are a student”

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

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)  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  Takes data IN  Keyboard, Mouse, Game Controller, Microphone  Output  Pushes, places data OUT  Display, Speakers, Printers

Programs and Digital Data  Programs  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

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

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

Conditional Logic  if(expression)  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)  Detailed from:

Comparing Strings  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

Exceptions and Exception Handling  Exceptions are…  “Exceptional” events  Unexpected events, errors during runtime  Unhandled exceptions? Stack trace and application death  Handled with try/catch/finally blocks  Try block “attempts” to run the code in question  Catch block handles the exception(s) that may occur  Finally block, optional, always executes

Test 02 Material

Loops  for  “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’  ‘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  Lists  Generic Collections

Files  OpenFileDialog  Used to load file from location  SaveFileDialog  Used to select file save location  BOTH very User friendly!

OpenFileDialog

SaveFileDialog

Random Numbers in C#  Provided from: System.Random  Is ONLY pseudo-random  Produces a finite set of values with equal probability  Not truly random, follows a mathematical algorithm  Created with OR without seed value  Common methods used:  Next()  Next(int)  Next(int, int)  NextDouble()

Creating and using a Random Object

Usage & Expected Results of Random Methods

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  Methods  Break out ‘steps’  Easier to test  Easier to visualize

Methods & Modularizing Your Code Example

Arrays

Sample Questions from Blackboard Wiki

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

What is the difference between a high-level and a low-level language?  Low-Level  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 TYPEIDENTIFIER

Describe ‘&&’ and ‘||’ and how they work.  && (AND)  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!)”

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  striing 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. But under what conditions?  When matching on a specific…  Value  Type  Enumeration  …other data

What does a ‘break’ statement do in a loop?  It stops (BREAKS) loop execution  Code continues, no further loop iterations

What does a ‘continue’ statement do in a loop?  Goes to the next iteration  CONTINUES loop execution, by skipping current iteration

What are preconditions and postconditions for a method?  PRECONDITIONS  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?  VOID 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?