Computing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects

Size: px
Start display at page:

Download "Computing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects"

Transcription

1

2 Computing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects C# is fully object-oriented: Everything is an Object: Simple Types, User-Defined Types, even Methods (c)schmiedecke 13 C#-3-Data and Objects 2

3 int, double, char, bool byte, sbyte, short, ushort, uint, long, ulong float, decimal string are Objects shorthand-aliases for System Types System.Int32, System.Double, System.Char... All are.net-types, i.e. common to all.net languages int a = 100; int b = new System.Int32(100); (c)schmiedecke 13 C#-3-Data and Objects 3

4 //Simple Types are.net System Types int mynumber mm System.Int32 mysecondnumber = 12; if (mysecondnumber is int) smile();// identical Type if (mynumber is Int32) smile(); // identical Type //All expected implicit numerical Conversions int a = 1234; decimal b = a; //Explicit numerical conversions //possible loss of information const double PI = 3.141; readonly int truncatedpi = (int)pi; // only 3 (c)schmiedecke 13 C#-3-Data and Objects 4

5 Static class System.Convert does it almost always overflow-checked Names of.net Types Convert.ToBoolean(val) Convert.ToByte(val) Convert.ToChar(val) Convert.ToDecimal(val) Convert.ToInt32(val) Convert.ToString(val)... //val can be any type that "works" exception, if value does not fit (c)schmiedecke 13 C#-3-Data and Objects 5

6 class Names { string firstname; string surname; public Names(string firstname, string surname) { public static implicit operator Name(Names names) { return new Name(names.surname + ", "+names.firstname); class Name { string Name; public Name(string name) { this.name = name; public static explicit operator Names(Name name) { string[] words = name.split(','); return new Name(words[1], words[0]); Names mynames = new Names("Ilse", "Schmiedecke"); Name myname = names; // implicit conversion Names reconstructed = (Names)myName; // explicit conversion (c)schmiedecke 13 C#-3-Data and Objects 6

7 Simple Types own operators +(a,b) identical to a+b Operators are like global static methods Operators can be user-defined through overloading: public static bool operator+ (MyType x, MyType y) { return Combine (x, y); Operators are functions, i.e. they must return a value (c)schmiedecke 13 C#-3-Data and Objects 7

8 It is sometimes useful to add an amout of time to a given time: The trip takes me 3 hours 40, it is now 12:25. When will i arrive? Write an overloaded + operator to your Time class and test it! public static Time operator+ (Time now, Time duration) {... Do the same for the - operator : I need to be there at..., when must i leave? (c)schmiedecke 13 C#-3-Data and Objects 8

9 Simple Types are Value Types Class Instances are Reference Types a: c: 100 int a = 100; Cloud c = new Cloud(); But Simple Types are objects, too? (c)schmiedecke 13 C#-3-Data and Objects 9

10 Class instances are "operating" objects, need an independant lifecycle Simple type "data" are stored and passed by operating objects, lifespan should depend on them. Data Structures are like "big" Simple Types Enumerations are like integers In C#, Enumerations and Structs are Value Types (c)schmiedecke 13 C#-3-Data and Objects 10

11 Structs encapsulate data types like classes no "default" constructor simply declare a variable! custom constructors possible (for initialization) no type hierarchy Contain just like classes: Fields (static and instance), Properties Methods Delegates Indexer (c)schmiedecke 13 C#-3-Data and Objects 11

12 Use Struct without constructor struct Car { int Power; string Type; int YearOfProduction; int age { get {return CurrentYear-YearOfProduction; Car mynewcar; // no constructor needed mynewcar.power = 25; mynewcar.type = "Trabant"; (c)schmiedecke 13 C#-3-Data and Objects 12

13 Class object with own lifecycle, stored on heap inheritance and polymorphism new (constructor call) required for object construction Stuct: Data Structure, stored directly in a variable Lifecycle depends on the variable no inheritance, no polmorphism no parameterless constructor; construction by declaration, "new" optional for initialization (c)schmiedecke 13 C#-3-Data and Objects 13

14 struct Car { int Power; string Type; int YearOfProduction; int age { get {return CurrentYear-YearOfProduction; public void method() { Car mynewcar; mynewcar.power = 25; mynewcar.type = "Trabant"; // mynewcar is lost! public void method(car paramcar) { paramcar.power = 25; paramcar.type = "Trabant"; // paramcar is lost! (c)schmiedecke 13 C#-3-Data and Objects 14

15 Class Limousine{ int Power; string Type; int YearOfProduction; int age { get {return CurrentYear-YearOfProduction; public void method() { Limousine mynewcar; mynewcar.power = 25; mynewcar.type = "Trabant"; // mynewcar is lost! public void method(limousine paramcar) { paramcar.power = 25; paramcar.type = "Trabant"; // paramcar is modified and survives! (c)schmiedecke 13 C#-3-Data and Objects 15

16 Reference type objects live as long as they are referenced Value type objects are destroyed when execution leaves the surrounding block. Value parameters are copied into the method method has no effect on them Reference parameters are referred to by the method method can have effect on them class Names { string firstname; string surname; struct Name { string name; static void deleteentries(names names, Name name) { names.firstname = "deleted"; // reference Type deleted names.surname = "deleted"; name.name = "deleted"; // value type only copy deleted (c)schmiedecke 13 C#-3-Data and Objects 16

17 A Struct is a Utility Data Type "Service" to the Program Used for storing and passing information e.g. Point, personaldatasheet, Contract,... important, where created an kept! Classes are Solutions, program units Using data to do work as a team can be derived from each other, implement interfaces... "Global players" e.g. Drawing, Form, Department, Task, Problem, Connection,... (c)schmiedecke 13 C#-3-Data and Objects 17

18 Would it be a good idea to define Time as a Struct? public struct Time { private int hour; private in minute;... (c)schmiedecke 13 C#-3-Data and Objects 18

19 Enumerations are types of small sets of named values Mapped to integers, can be changed to long, short, byte. Explicit mapping is possible arithmetics are allowed (even if "overflowing" the enum!) automatic ToString() and static Parse(Type, string) method public enum Weekday { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday // mapped to 0-6 private enum Day : byte // only 1 byte long { Sun=1, Mon, Tue, Wed, Thu, Fri, Sat // mapped to 1-7 Weekday today = Weekday.Wednesday; if (today > Weekday.Friday) Shout("Weekend!"); (c)schmiedecke 13 C#-3-Data and Objects 19

20 per default, enums are ints different number size possible particularly useful for binary masking i.e. using logical bit operations to set or read a state enum Access: byte {personal=1, group=2, all=4 Access currentaccess = Access.personal Access.group; if ((currentaccess & Access.personal)!= 0) grantaccess(); (c)schmiedecke 13 C#-3-Data and Objects 20

21 Add days of the week to your Date class, using an enum, and modify your output method accordingly: If you are clever, you can even compute the day from the date, or check it on input... but that is optional. Write a string method ToTurkishDate, using another enumeration. public string ToTurkishDate() {... (c)schmiedecke 13 C#-3-Data and Objects 21

22 Collections are sets of data stored under a common name Arrays: Data of identical type stored in a fixed-size area in memory, accessed by indeces. General Collections: Classes for storing varying amounts of data different access strategies different special properties (c)schmiedecke 13 C#-3-Data and Objects 22

23 Arrays contain data of identical type access via numerical index, starting with O overflow and underflow cause exceptions dimensioning as "jagged arrays": type [][][] System.Array provides poperty Length int[][] jagged = new int[3][]; jagged[0] = new int[2]; jagged[0][0] = 1; jagged[0][1] = 2; jagged[1] = new int[1]; jagged[2] = new int[3] { 3, 4, 5 ; for (int i = 0; i < jagged.length; i++) { int[] innerarray = jagged[i]; foreach (int number in innerarray) { Console.Write(number + " "); Console.WriteLine(); (c)schmiedecke 13 C#-3-Data and Objects 23

24 Block arrays are defined as type [,,, ] Length property of class Array applies in total GetLength method gives dimension lengths Block arrays are nicer, but slower then jagged arrays static void Main() { int[,,] threedimensional = new int[3, 5, 4]; threedimensional[0, 0, 0] = 1; threedimensional[0, 1, 0] = 2; threedimensional[0, 2, 0] = 3; threedimensional[0, 3, 0] = 4; threedimensional[0, 4, 0] = 5; threedimensional[1, 1, 1] = 2; threedimensional[2, 2, 2] = 3; threedimensional[2, 2, 3] = 4; for (int z = 0; z < threedimensional.getlength(2); z++) { for (int y = 0; y < threedimensional.getlength(1); y++) { for (int x = 0; x < threedimensional.getlength(0); x++) { Console.Write(threeDimensional[x, y, i]); Console.WriteLine(); //lines of 3 values Console.WriteLine(); // blocks of 5 lines Console.Writeline("Total Length: "+ threedimensional.length); // 60 (c)schmiedecke 13 C#-3-Data and Objects 24

25 Properties pretend to be fields - but are secured Indexers let classes pretend to be arrays: Object can be accessed using square brackets "index" needs not be numerical, though class FakeArray { this string [int index] { get { int choice = index % 3; if (choice == 0) return "cow"; else if (choice == 1) return "dog"; else return "cat"; private set { FakeArray myarray = new FakeArray(); string mystring = myarray[18]; // cow mystring = myarray[2]; // cat myarray[22] = "spider"; // ignored... (c)schmiedecke 13 C#-3-Data and Objects 25

26 string has an indexer you can access individual chars using square brackets We will learn about List-tpye collections they all have indexers so you can access any List object as if it was an array and many more string word = "Mysecretcodeword"; char firstletter = word[0]; (c)schmiedecke 13 C#-3-Data and Objects 26

27 Begin to design the Appointment type and an Organizer according to Assinment 2. Use an Array to (prototypically) store the appointments. (c)schmiedecke 13 C#-3-Data and Objects 27

28 class Class Model IEnumerable + GetEnumerator() : Enumerator ICollection - Count: int + CopyTo() : ICollection IList - IsFixedSize: boolean - IsReadOnly: boolean - this: IList IDictionary - IsFixedäSize: boolean - IsReadOnly: boolean - Keys: ICollection - this: IDictionary - Values: ICollection + Add() : void + Clear() : void + Contains() : boolean + Add() : void + IndexOf() : int + Clear() : void + Insert() : void + Contains() : boolean + Remove() : void + GetEnumerator() : Enumerator (c)schmiedecke 13 + RemoveAt() : void C#-3-Data and + Objects Remove() : void 28

29 Namespace System.Collections IEnumerable foreach loop is applicable ICollection allows copying between Collections IList indexed collections, fixed order Indexes IDictionary associative Collection, mapping keys to Values static void Main() { int[] arr = new int[3]; arr[0] = 2; arr[1] = 3; arr[2] = 5; LinkedList list = new LinkedList(arr); // Copy to List Hashmap map = new Hashmap() hashmap.add("key1", "value1"); ArrayList list2 = new ArrayList(); map.copyto(list2); // Copy to List (c)schmiedecke 13 C#-3-Data and Objects 29

30 Indexers make objects accessable like arrays Declare "this" property (getter and setter) index may be any type, most commonly int overloading possible! class MockArray { private string low = "low", high = "high"; public string this[int index] { get { if (index < 0) throw new IndexOutOfRangeException(); else if index < 10 ) return low; else return high; set { if (index < 0) throw new IndexOutOfRangeException(); else if index < 10 ) low = value; else high = value; MockArray mock = new MockArray(); mock[12] = mock[8]; (c)schmiedecke 13 C#-3-Data and Objects 30

31 Lists are flexible numbered Collections with fixed order of elements Accessable using an Indexer Most important IList-Implementations ArrayList, Linkedlist, Array SortedList Stack, Queue ArrayList list = new ArrayList(); list.add(2); list.add(3); list.add(7); foreach (object prime in list) Console.WriteLine((int)prime); for (int i = 0; i < list.count; i++) Console.WriteLine((int)(list[i])); list.add(13); list.insert(3, 11); // foreach loop // indexer access (c)schmiedecke 13 C#-3-Data and Objects 31

32 IDictionary describes Maps, or associative collections Key-Value-Pairs Hashtable implements IDictionary Hashtable hashtable = new Hashtable(); hashtable.add("area", 1000); hashtable.add("perimeter", 55); hashtable.add("mortgage", 540); hashtable["year of construction"] = 1955; // Indexer if (hashtable.contains("area")) int area = (int)hashtable["area"]; foreach (object key in hashtable.keys) Console.WriteLine(key.ToString + ": " + hashtable[key].tostring()); (c)schmiedecke 13 C#-3-Data and Objects 32

33 class CollectionsGeneric IEnumerable<T> + GetEnumerator() : Enumerator<T> class Class Model IEnumerable + GetEnumerator() : Enumerator ICollection<T> - Count: int - IsReadOnly: boolean + Add() : void + Clear() : void + Contains() : boolean + CopyTo() : ICollection<T> + Remove() : void IList - IsFixedSize: boolean - IsReadOnly: boolean - this: IList + Add() : void + Clear() : void + Contains() : boolean + IndexOf() : int + Insert() : void + Remove() : void + RemoveAt() : void ICollection - Count: int + CopyTo() : ICollection IDictionary - IsFixedäSize: boolean - IsReadOnly: boolean - Keys: ICollection - this: IDictionary - Values: ICollection + Add() : void + Clear() : void + Contains() : boolean + GetEnumerator() : Enumerator + Remove() : void IList<T> IDictionary<T, Key> - this: IList<T> - Keys: ICollection<T> - this: IDictionary<T, Key> + IndexOf() : int - Values: ICollection<T> + Exists() : void + Insert() : void + Add() : void + RemoveAt() : void + ContainsKey() : boolean (c)schmiedecke 13 + TryGetValue() : <T> C#-3-Data and Objects 33

34 Generic Collections result from a review process type safe access thread safe access much better performance Dictionary<string, int> dict = new Dictionary<string, int>(); dict.add("area", 1000); dict.add("perimeter", 55); dict.add("mortgage", 540); dict["year of construction"] = 1955; // Indexer if (dict.containskey("area")) int area = dict["area"]; // no type casting foreach (string key in dict.keys) Console.WriteLine(key + ": " + dict[key]()); (c)schmiedecke 13 C#-3-Data and Objects 34

35 Implementing IEnumerable requires keeping track of cursors etc. Instead, provide an enumerable list to be used by an iterator keyword "yield return" adds entries to an iterator list Compiler builds iterator. void PrintPowerList() { foreach (int value in ComputePower(2, 30)) Console.WriteLine(value); public static IEnumerable<int> ComputePower (int number, int exponent) { int exponentnum = 0; int numberresult = 1; while (exponentnum < exponent) { numberresult *= number; exponentnum++; yield return numberresult; (c)schmiedecke 13 C#-3-Data and Objects 35

36 For your organizer, choose an appropriate collection to collect all entered dates to keep the collection sorted to be able to output all appointments to be able to look for an appointment. (c)schmiedecke 13 C#-3-Data and Objects 36

37 (c)schmiedecke 13 C#-3-Data and Objects 37

classes, inheritance, interfaces, polymorphism simple and structured types, generics type safeness

classes, inheritance, interfaces, polymorphism simple and structured types, generics type safeness C# is an object oriented language very much like Java a little more modern (int is an object) much more features and add-ons (to keep experienced programmers happy) classes, inheritance, interfaces, polymorphism

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming Objects self-contained working units encapsulate data and operations exist independantly of each other (functionally, they may depend) cooperate and communicate to perform a

More information

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals C# Types Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:

More information

Industrial Programming

Industrial Programming Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 C# Types Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:

More information

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh C# Fundamentals Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 1 2018/19 H-W. Loidl (Heriot-Watt Univ) F20SC/F21SC 2018/19

More information

6: Arrays and Collections

6: Arrays and Collections 6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.

More information

6: Arrays and Collections

6: Arrays and Collections 6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.

More information

Introduce C# as Object Oriented programming language. Explain, tokens,

Introduce C# as Object Oriented programming language. Explain, tokens, Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation

More information

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class. 1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information

Last Time. Arrays. Arrays. Jagged Arrays. foreach. We began looking at GUI Programming Completed talking about exception handling

Last Time. Arrays. Arrays. Jagged Arrays. foreach. We began looking at GUI Programming Completed talking about exception handling Last Time We began looking at GUI Programming Completed talking about exception handling Arrays, Collections, Hash Tables, 9/22/05 CS360 Windows Programming 1 9/22/05 CS360 Windows Programming 2 Arrays

More information

DigiPen Institute of Technology

DigiPen Institute of Technology DigiPen Institute of Technology Presents Session Two: Overview of C# Programming DigiPen Institute of Technology 5001 150th Ave NE, Redmond, WA 98052 Phone: (425) 558-0299 www.digipen.edu 2005 DigiPen

More information

Duhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain

Duhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Overview. C# program structure. Variables and Constant. Conditional statement (if, if/else, nested if

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 Namespaces Classes Fields Properties Methods Attributes Events Interfaces (contracts) Methods Properties Events Control Statements if, else, while, for, switch foreach Additional Features Operation Overloading

More information

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations , 1 C#.Net VT 2009 Course Contents C# 6 hp approx. BizTalk 1,5 hp approx. No exam, but laborations Course contents Architecture Visual Studio Syntax Classes Forms Class Libraries Inheritance Other C# essentials

More information

.Net Technologies. Components of.net Framework

.Net Technologies. Components of.net Framework .Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.

More information

DAD Lab. 1 Introduc7on to C#

DAD Lab. 1 Introduc7on to C# DAD 2017-18 Lab. 1 Introduc7on to C# Summary 1..NET Framework Architecture 2. C# Language Syntax C# vs. Java vs C++ 3. IDE: MS Visual Studio Tools Console and WinForm Applica7ons 1..NET Framework Introduc7on

More information

Uka Tarsadia University MCA ( 3rd Semester)/M.Sc.(CA) (1st Semester) Course : / Visual Programming Question Bank

Uka Tarsadia University MCA ( 3rd Semester)/M.Sc.(CA) (1st Semester) Course : / Visual Programming Question Bank Unit 1 Introduction to.net Platform Q: 1 Answer in short. 1. Which three main components are available in.net framework? 2. List any two new features added in.net framework 4.0 which is not available in

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

NOIDATUT E Leaning Platform

NOIDATUT E Leaning Platform NOIDATUT E Leaning Platform Dot Net Framework Lab Manual COMPUTER SCIENCE AND ENGINEERING Presented by: NOIDATUT Email : e-learn@noidatut.com www.noidatut.com C SHARP 1. Program to display Hello World

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

DC69 C# &.NET JUNE C# is a simple, modern, object oriented language derived from C++ and Java.

DC69 C# &.NET JUNE C# is a simple, modern, object oriented language derived from C++ and Java. Q.2 a. What is C#? Discuss its features in brief. 1. C# is a simple, modern, object oriented language derived from C++ and Java. 2. It aims to combine the high productivity of Visual Basic and the raw

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information

Enumerated Types. Mr. Dave Clausen La Cañada High School

Enumerated Types. Mr. Dave Clausen La Cañada High School Enumerated Types Mr. Dave Clausen La Cañada High School Enumerated Types Enumerated Types This is a new simple type that is defined by listing (enumerating) the literal values to be used in this type.

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming Objects self-contained working units encapsulate data and operations exist independantly of each other (functionally, they may depend) cooperate and communicate to perform a

More information

A Comparison of Visual Basic.NET and C#

A Comparison of Visual Basic.NET and C# Appendix B A Comparison of Visual Basic.NET and C# A NUMBER OF LANGUAGES work with the.net Framework. Microsoft is releasing the following four languages with its Visual Studio.NET product: C#, Visual

More information

Objectives. Describe ways to create constants const readonly enum

Objectives. Describe ways to create constants const readonly enum Constants Objectives Describe ways to create constants const readonly enum 2 Motivation Idea of constant is useful makes programs more readable allows more compile time error checking 3 Const Keyword const

More information

Object-Oriented Programming in C# (VS 2015)

Object-Oriented Programming in C# (VS 2015) Object-Oriented Programming in C# (VS 2015) This thorough and comprehensive 5-day course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes

More information

EECS402 Lecture 24. Something New (Sort Of) Intro To Function Pointers

EECS402 Lecture 24. Something New (Sort Of) Intro To Function Pointers The University Of Michigan Lecture 24 Andrew M. Morgan Savicth: N/A Misc. Topics Something New (Sort Of) Consider the following line of code from a program I wrote: retval = oplist[whichop] (mainary, arysize);

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Object-Oriented Programming in C# (VS 2012)

Object-Oriented Programming in C# (VS 2012) Object-Oriented Programming in C# (VS 2012) This thorough and comprehensive course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes the C#

More information

Cloning Enums. Cloning and Enums BIU OOP

Cloning Enums. Cloning and Enums BIU OOP Table of contents 1 Cloning 2 Integer representation Object representation Java Enum Cloning Objective We have an object and we need to make a copy of it. We need to choose if we want a shallow copy or

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Sunday, Tuesday: 9:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming A programming

More information

CS349/SE382 A1 C Programming Tutorial

CS349/SE382 A1 C Programming Tutorial CS349/SE382 A1 C Programming Tutorial Erin Lester January 2005 Outline Comments Variable Declarations Objects Dynamic Memory Boolean Type structs, enums and unions Other Differences The Event Loop Comments

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

Applied object oriented programming. 4 th lecture

Applied object oriented programming. 4 th lecture Applied object oriented programming 4 th lecture Today Constructors in depth Class inheritance Interfaces Standard.NET interfaces IComparable IComparer IEquatable IEnumerable ICloneable (and cloning) Kahoot

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time

More information

Module 1. An Introduction to C# Module 2. Classes and Objects. Vasundhara Sector 14-A, Plot No , Near Vaishali Metro Station,Ghaziabad

Module 1. An Introduction to C# Module 2. Classes and Objects. Vasundhara Sector 14-A, Plot No , Near Vaishali Metro Station,Ghaziabad Module 1. An Introduction to C# What is.net? What is the CLR? The FCL Primitive Types Namespaces Statements and Expressions Operators Module Module 2. Classes and Objects Constructors Reference Types Object

More information

Francesco Nidito. Programmazione Avanzata AA 2007/08

Francesco Nidito. Programmazione Avanzata AA 2007/08 Francesco Nidito in the Programmazione Avanzata AA 2007/08 Outline 1 2 3 in the in the 4 Reference: Micheal L. Scott, Programming Languages Pragmatics, Chapter 7 What is a type? in the What is a type?

More information

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference

More information

An Introduction to C++

An Introduction to C++ An Introduction to C++ Introduction to C++ C++ classes C++ class details To create a complex type in C In the.h file Define structs to store data Declare function prototypes The.h file serves as the interface

More information

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine

More information

C#: framework overview and in-the-small features

C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 C++\CLI Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 Comparison of Object Models Standard C++ Object Model All objects share a rich memory model: Static, stack, and heap Rich object life-time

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP OOP Object oriented programming Polymorphism Encapsulation Inheritance OOP Class concepts Classes can contain: Constants Delegates Events Fields Constructors Destructors Properties Methods Nested classes

More information

Question And Answer.

Question And Answer. Q.1 What would be the output of the following program? using System; namespaceifta classdatatypes static void Main(string[] args) inti; Console.WriteLine("i is not used inthis program!"); A. i is not used

More information

Structures and Pointers

Structures and Pointers Structures and Pointers Comp-206 : Introduction to Software Systems Lecture 11 Alexandre Denault Computer Science McGill University Fall 2006 Note on Assignment 1 Please note that handin does not allow

More information

Introduction to.net, C#, and Visual Studio. Part I. Administrivia. Administrivia. Course Structure. Final Project. Part II. What is.net?

Introduction to.net, C#, and Visual Studio. Part I. Administrivia. Administrivia. Course Structure. Final Project. Part II. What is.net? Introduction to.net, C#, and Visual Studio C# Programming Part I Administrivia January 8 Administrivia Course Structure When: Wednesdays 10 11am (and a few Mondays as needed) Where: Moore 100B This lab

More information

TYPES, VALUES AND DECLARATIONS

TYPES, VALUES AND DECLARATIONS COSC 2P90 TYPES, VALUES AND DECLARATIONS (c) S. Thompson, M. Winters 1 Names, References, Values & Types data items have a value and a type type determines set of operations variables Have an identifier

More information

CSCI312 Principles of Programming Languages!

CSCI312 Principles of Programming Languages! CSCI312 Principles of Programming Languages! Chapter 5 Types Xu Liu! ! 5.1!Type Errors! 5.2!Static and Dynamic Typing! 5.3!Basic Types! 5.4!NonBasic Types! 5.5!Recursive Data Types! 5.6!Functions as Types!

More information

C# Language Reference

C# Language Reference C# Language Reference Owners: Anders Hejlsberg and Scott Wiltamuth File: clangref Last saved: 6/26/2000 Last printed: 7/10/2000 Version 0.17b Copyright Microsoft Corporation 1999-2000. All Rights Reserved.

More information

Lecture 3. The syntax for accessing a struct member is

Lecture 3. The syntax for accessing a struct member is Lecture 3 Structures: Structures are typically used to group several data items together to form a single entity. It is a collection of variables used to group variables into a single record. Thus a structure

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features

More information

22c:111 Programming Language Concepts. Fall Types I

22c:111 Programming Language Concepts. Fall Types I 22c:111 Programming Language Concepts Fall 2008 Types I Copyright 2007-08, The McGraw-Hill Company and Cesare Tinelli. These notes were originally developed by Allen Tucker, Robert Noonan and modified

More information

VB.NET MOCK TEST VB.NET MOCK TEST III

VB.NET MOCK TEST VB.NET MOCK TEST III http://www.tutorialspoint.com VB.NET MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to VB.Net. You can download these sample mock tests at your local

More information

PASCAL. PASCAL, like BASIC, is a computer language. However, PASCAL, unlike BASIC, is a Blocked Structured Language (BASIC is known as unstructured).

PASCAL. PASCAL, like BASIC, is a computer language. However, PASCAL, unlike BASIC, is a Blocked Structured Language (BASIC is known as unstructured). PASCAL 11 OVERVIEW OF PASCAL LANGUAGE PASCAL, like BASIC, is a computer language However, PASCAL, unlike BASIC, is a Blocked Structured Language (BASIC is known as unstructured) Let look at a simple {BLOCK

More information

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Module 4: Data Types and Variables

Module 4: Data Types and Variables Module 4: Data Types and Variables Table of Contents Module Overview 4-1 Lesson 1: Introduction to Data Types 4-2 Lesson 2: Defining and Using Variables 4-10 Lab:Variables and Constants 4-26 Lesson 3:

More information

C++: Const Function Overloading Constructors and Destructors Enumerations Assertions

C++: Const Function Overloading Constructors and Destructors Enumerations Assertions C++: Const Function Overloading Constructors and Destructors Enumerations Assertions Const const float pi=3.14159; const int* pheight; // defines pointer to // constant int value cannot be changed // pointer

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Advanced Programming Methods. Lecture 9 - Generics, Collections and IO operations in C#

Advanced Programming Methods. Lecture 9 - Generics, Collections and IO operations in C# Advanced Programming Methods Lecture 9 - Generics, Collections and IO operations in C# Content Language C#: 1. Generics 2. Collections 3. IO operations C# GENERICS C# s genericity mechanism, available

More information

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction 1. Which language is not a true object-oriented programming language? A. VB 6 B. VB.NET C. JAVA D. C++ 2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a)

More information

CMSC 4023 Chapter 11

CMSC 4023 Chapter 11 11. Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language Examples Parameterized Abstract Data Types Encapsulation Constructs Naming Encapsulations

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

Language Specification

Language Specification # Language Specification File: C# Language Specification.doc Last saved: 5/7/2001 Version 0.28 Copyright? Microsoft Corporation 1999-2000. All Rights Reserved. Please send corrections, comments, and other

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

5/23/2015. Core Java Syllabus. VikRam ShaRma

5/23/2015. Core Java Syllabus. VikRam ShaRma 5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5

More information

Lecture 12: Data Types (and Some Leftover ML)

Lecture 12: Data Types (and Some Leftover ML) Lecture 12: Data Types (and Some Leftover ML) COMP 524 Programming Language Concepts Stephen Olivier March 3, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts Goals

More information

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content Core Java - SCJP Course content NOTE: For exam objectives refer to the SCJP 1.6 objectives. 1. Declarations and Access Control Java Refresher Identifiers & JavaBeans Legal Identifiers. Sun's Java Code

More information

Lecture Notes on Programming Languages

Lecture Notes on Programming Languages Lecture Notes on Programming Languages 37 Lecture 04: Data Types and Variables All programming languages provide data types. A data type describes a set of data values and a set of predefined operations

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer April 20, 2015 OOPP / C++ Lecture 3... 1/23 New Things in C++ Object vs. Pointer to Object Optional Parameters Enumerations Using an enum

More information

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

CISC 3130 Data Structures Fall 2018

CISC 3130 Data Structures Fall 2018 CISC 3130 Data Structures Fall 2018 Instructor: Ari Mermelstein Email address for questions: mermelstein AT sci DOT brooklyn DOT cuny DOT edu Email address for homework submissions: mermelstein DOT homework

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Introduction To C#.NET

Introduction To C#.NET Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However

More information

CSE 12 Week Eight, Lecture One

CSE 12 Week Eight, Lecture One CSE 12 Week Eight, Lecture One Heap: (The data structure, not the memory area) - A binary tree with properties: - 1. Parent s are greater than s. o the heap order - 2. Nodes are inserted so that tree is

More information

OVERVIEW ENVIRONMENT PROGRAM STRUCTURE BASIC SYNTAX DATA TYPES TYPE CONVERSION

OVERVIEW ENVIRONMENT PROGRAM STRUCTURE BASIC SYNTAX DATA TYPES TYPE CONVERSION Program: C#.Net (Basic with advance) Duration: 50hrs. C#.Net OVERVIEW Strong Programming Features of C# ENVIRONMENT The.Net Framework Integrated Development Environment (IDE) for C# PROGRAM STRUCTURE Creating

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

DC69 C# &.NET DEC 2015

DC69 C# &.NET DEC 2015 Q.2 a. Briefly explain the advantage of framework base classes in.net. (5).NET supplies a library of base classes that we can use to implement applications quickly. We can use them by simply instantiating

More information

Announcements/Follow-ups

Announcements/Follow-ups Announcements/Follow-ups Midterm #2 Friday Everything up to and including today Review section tomorrow Study set # 6 online answers posted later today P5 due next Tuesday A good way to study Style omit

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Microsoft. Microsoft Visual C# Step by Step. John Sharp

Microsoft. Microsoft Visual C# Step by Step. John Sharp Microsoft Microsoft Visual C#- 2010 Step by Step John Sharp Table of Contents Acknowledgments Introduction xvii xix Part I Introducing Microsoft Visual C# and Microsoft Visual Studio 2010 1 Welcome to

More information

Collections, Maps and Generics

Collections, Maps and Generics Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

More information

Multiple Choice: 2 pts each CS-3020 Exam #3 (CH16-CH21) FORM: EX03:P

Multiple Choice: 2 pts each CS-3020 Exam #3 (CH16-CH21) FORM: EX03:P Multiple Choice: 2 pts each CS-3020 Exam #3 (CH16-CH21) FORM: EX03:P Choose the BEST answer of those given and enter your choice on the Answer Sheet. You may choose multiple options, but the point value

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

Programming in Haskell Aug-Nov 2015

Programming in Haskell Aug-Nov 2015 Programming in Haskell Aug-Nov 2015 LECTURE 14 OCTOBER 1, 2015 S P SURESH CHENNAI MATHEMATICAL INSTITUTE Enumerated data types The data keyword is used to define new types data Bool = False True data Day

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing. CISC-124 20180115 20180116 20180118 We continued our introductory exploration of Java and object-oriented programming by looking at a program that uses two classes. We created a Java file Dog.java and

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

RTL Reference 1. JVM. 2. Lexical Conventions

RTL Reference 1. JVM. 2. Lexical Conventions RTL Reference 1. JVM Record Transformation Language (RTL) runs on the JVM. Runtime support for operations on data types are all implemented in Java. This constrains the data types to be compatible to Java's

More information

Chapter 11. Abstract Data Types and Encapsulation Concepts ISBN

Chapter 11. Abstract Data Types and Encapsulation Concepts ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts ISBN 0-321-49362-1 Chapter 11 Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language

More information