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

Size: px
Start display at page:

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

Transcription

1

2 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 simple and structured types, generics type safeness beautiful GUIs phantastic ready-made data types great libraries easy networking and webworking (efficient graphics processing) (c)schmiedecke C# and.net 2

3 value objects reference parameters block matrices unified type system properties indexer iterators delegates lambda expressions data queries don't worry, be happy! (c)schmiedecke C# and.net 3

4 CLS and CTS C#.NET J#.NET C++.NET VB.NET CIL CLR Windows (c)schmiedecke C# and.net 4

5 .NET no specific meaning, suggests web distribution current version: 4.0 CLS Common Language Specification specifies similar behaviour in.net languages e.g. parameter passing, argument evaluation, exception handling CTS Common Type System guarantees loss-free data exchange between.net languages CIL Common Intermediate Language Bytecode for efficient execution on Windows systems CLR Common Language Runtime executes CIL (c)schmiedecke C# and.net 5

6 Breakpoint Editor Solution Explorer Output (c)schmiedecke C# and.net 6

7 F5 shift+f5 Ctrl+F5 F11 F10 Shift+F11 F11 Step into F10 Step over Shift+F11 Step out Alt+Shift*Break Interrupt F5 Resume Shift+F5 Terminate Ctrl+F5 Restart (c)schmiedecke C# and.net 7

8 (c)schmiedecke C# and.net 8

9 (c)schmiedecke 13 C#-3-OO 9

10 Classes are types are "blueprints" for objects (heap objects, indefinite scope) can form type hierarchies by inheritance Namespaces are "containers" for types (classes -- and interfaces, enumerations, structs, delegates) may be nested determine their members' fully qualified name public classes (etc.) can be used, if they are referenced i.e. their path is known to the project using is a shorthand to omit the namespace path of a classname it is not an act of import! (c)schmiedecke 13 C#-2 - Classes and Objects 10

11 The following class definitions are equivalent: using System.IO; namespace fileutils { public class FileInformation { public void PrintFileInformation(string filename) { if (File.Exists(filename)) { string fileinfo = RetrieveFileInfo(filename); //... } } } } namespace fileutils { public class FileInformation { public void PrintFileInformation(string filename) { if (System.IO.File.Exists(filename)) { string fileinfo = RetrieveFileInfo(filename); //... } } } } (c)schmiedecke 13 C#-2 - Classes and Objects 11

12 C# Constructors (Destructors) Fields Properties Indexer Events Methods Overloaded Operators Inner Types JAVA Constructors Fields Methods Inner Types (c)schmiedecke 13 C#-2 - Classes and Objects 12

13 variables, instance and static should be private, for internal use only naming convention: camelcase (start with small letter) extra modifiers for constants: const (compiletime value) static const (global constant) readonly (immutable after initialization) (usually) public class Person { private char internalstatus; // cryptic on purpose private static int currentwaitingtime; public const int ID; } (c)schmiedecke 13 C#-2 - Classes and Objects 13

14 Programming best practice in all oo programs! private fields with get and set accessors preserve consistent state! shorthand declaration in C# readonly by providing a private setter or no setter at all class Person { private char internalstatus; // cryptic on purpose private static int currentwaitingtime; } private int id; public int Id { get { return id; } set { id = value; } } //automatic property: public int Id { get ; set } //with resticted access public int Id { get ; private set } (c)schmiedecke 13 C#-2 - Classes and Objects 14

15 Use Properties for robustness every setter checks for validity SetTime can simply use setters use of getters and setters is implicit: Hour = h; // setter is called return string.format( "{0:D2}:{1:D2}:{2:D2}", Hour, Minute, Second ); // getter is called (c)schmiedecke 13 C#-2 - Classes and Objects 15

16 void methods and functions like in Java naming convention PascalCase methods can take parameters and throw and handle exceptions (without declaring them) an instance method reads or modifies "its" instance fields a static method gets ist data from parameters. public class BankAccount { private decimal Balance; private decimal DebtLimit; private decimal Transit; public void Add(decimal amount) { } public void Transfer(decimal amount, BankAccount acc) { if (Balance + DebtLimit < amount) throw new BankingException(); Transit=amount; acc.add(amount); Transit=0; } } (c)schmiedecke 13 C#-2 - Classes and Objects 16

17 Each object has an identity a state, with characteristic features (constants) and changing features (properties) state initialization at object construction using a constructor (or direct initialization) implicit default constructor initializes to 0, false and null public class NewTime { public NewTime(int h, int, m, int s) // constr. w/ 3 params { SetTime(h, m, s); } public NewTime(int h) : this(h, 0, 0){ } // using constructor // initializer : this //... } (c)schmiedecke 13 C#-2 - Classes and Objects 17

18 Overloading: "Defining another method using the same name, but different parameters, either in number or type." C# allows for constructor overloading method overloading operator overloading implicit default constructor initializes to 0, false and null overloading constructors remove implicit constructor when overloading, make sure to add a default constructor! (c)schmiedecke 13 C#-2 - Classes and Objects 18

19 Constuctor definition like a method with name of class. Constructor overloading: Define more than one constructor. Constructor initializer: reuse another constructor (rather than redundantly redifining it) using :this( ) - body starts with calling other constructor. public class NewTime { public NewTime(int h, int, m, int s) // constr. w/ 3 params { SetTime(h, m, s); } public NewTime(int h) : this(h, 0, 0){ } // using constructor // initializer : this //... } (c)schmiedecke 13 C#-2 - Classes and Objects 19

20 Time has no overloaded constructors but public properties that should be initialized Object initilizers "invent" a constructor by calling it using the names of the properties as parameter names no need to mention all, others initialized to 0 / false / null Time MyTime = new Time(Hour=11, Minute=15, Second=0); Time YourTime = new Time(Hour=14); // all others 0 (c)schmiedecke 13 C#-2 - Classes and Objects 20

21 Test Methods are static instantiate the class under testing assign values to ist fields an properties legal and forbidden ones! call all methods with different parameters lagal and forbidden ones! check and output the result. Collect Test Methods in a static Test Class In the Main method, call the different tests and evaluate them. (c)schmiedecke 13 C#-2 - Classes and Objects 21

22 Must be static Must be members of a static class Can only access public properties and methods of the extended class. public static class TimeExtensions { public static Time AddHours( this Time tm, int hours) { Time newtime = new Time(tm.Hour, tm.minute, tm.second); newtimehour = (tm.hour + hours) % 24; return NewTime; } } Time mytime = new Time (22, 12, 08); mytime = mytime.addhours(3); Console.WriteLine(mytime); // 01:12:08 (c)schmiedecke 13 C#-2 - Classes and Objects 22

23 Warning! A n instance method with the same signature HIDES the extension So, if later on, a similar method is added to the class or to one of ist superclasses, your extension method will no longer be called! (c)schmiedecke 13 C#-2 - Classes and Objects 23

24 none, internal accessible within assembly (=project) OR public accessible from anywhere static contains only static members abstract only for subclassing, no instantiation OR sealed subclassing prohibited OR none find contradicting combinations! (c)schmiedecke 13 C#-2 - Classes and Objects 24

25 public accessible anywhere none, internal accessible within assembly (=project) protected accessible in subclasses private accessible within class (even other instances) static member belongs to class, not instance abstract not for fields virtual method: open for polymorphic overriding override method: polymorphic overriding const field: compiletime constant readonly field: immutable after initialization (c)schmiedecke 13 C#-2 - Classes and Objects 25

26 static fields are not specific to instances the type manages them for all instances (family property) Class Windsor Chief: Queen E II Res: Buckingham P Home: Windsor C. static methods cannot access the instance use static fields, call static methods receive data via parameters create instance to call instance methods Charles William Elizabeth II static classes Kate contain only static members (c)schmiedecke 13 C#-2 - Classes and Objects 26

27 could Compute day of the week for a given Date Convert Date to other calendar Validate a Date Compute next leap year for a given Date Provide national output formats for Date All makes sense without storing a Date, i.e. without an instance state. (But it would also make sense as instance methods) static class DateUtilities { public static string DayOfTheWeek(Date date) {...} public static bool IsValidDate (int day, int month, int year) { } } (c)schmiedecke 13 C#-2 - Classes and Objects 27

28 Classes from different namespaces: add "using" directive using OrganizerBackend; Classes from different projects or solutions, or from libraries add Reference to your project (c)schmiedecke 13 C#-3-OO 28

29 (c)schmiedecke 13 C#-3-OO 29

30 int, double, char, bool byte, sbyte, short, ushort, uint, long, ulong float, decimal string are.net-types, defined in the System namespace are Objects All are.net-types, i.e. common to all.net languages All expected implicit and explicit number conversions double val = 3; // implicit conversion from int to double int size = (int) // explicit converion (c)schmiedecke 13 C#-3-Data and Objects 30

31 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 31

32 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 32

33 Use Constructor to create a new Object with "old" content string[] mywords = { "All", "my", "words", "and", "ideas" }; List<string> morewords = new List<string> (mywords); public class List<T> { public List<T>(T[] array) { foreach (T t in array) this.add(t); } } (c)schmiedecke 13 C#-3-OO 33

34 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 34

35 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 35

36 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 36

37 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 37

38 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 38

39 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 39

40 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 40

41 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 41

42 static void Main() { Person Annie = new Person("smith, annie"); Person Bruce = new Person("wild, bruce"); Exchange(Annie, Bruce) Console.WriteLine(Annie.Name, Bruce.Name); } static void Exchange (Person A, Person B) { Person C = A; A = B; B = C; } // no effect! { string c = A.Name; A.Name = B.Name; B.Name = c; } Annie Bruce smith, annie wild, bruce A B C Parameter passing by (reference) value copies to local variables (c)schmiedecke 13 C#-3-OO 42

43 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 43

44 (c)schmiedecke 13 C#-3-OO 44

45 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 45

46 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 46

47 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 47

48 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 48

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

50 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 50

51 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 51

52 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 52

53 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 53

54 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 54

55 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 55

56 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 56

57 Get all the Appointments today as a List List<Appointment> datalist = new List<Appointment>(); foreach (Appointment app in myorganizer.entries) if (app.date.compareto(datetime.now) == 0) list.add(app); var result = from app in myorganizer.entries where app.date.compareto(datetime.now) == 0 select app; List<Appointment> datalist = result.tolist<appointment>(); (c)schmiedecke 13 C#-3-OO 57

58 (c)schmiedecke 13 C#-3-OO 58

59 class TypeHierarchy IEnumerable IEnumerable<T> ICollection ICollectio<T> IDictionary IList HashTable ArrayList LinkedList ILst<T> IDictionary<T> ArrayList<T> List<T> Dictionary<T> (c)schmiedecke 13 C#-3-OO 59

60 Interfaces serve as common types for varying implementations a programming "contract" Examples: allow a prototype implementation to be replaced by a production implementation without effect on code tell another programming team what I expect from them specify the contents of a library or have a common variable type for a variety of values. public interface IRegister { public bool isexpired(datetime date); // abstract method } (c)schmiedecke 13 C#-3-OO 60

61 Gain flexibility: Use superclasses as variable types to allow for compatibility! Even better: use Interface type variables! IRegister<T> mylist = new RegisterPrototype<T>(); // simply replace by SecureRegister later. Careful with Generics! general and generic types are not directly compatible ArrayList list = new ArrayList<string>; // Compiler error! (c)schmiedecke 13 C#-3-OO 61

62 Like in Java, Interfaces are fully abstract classes can extend further interfaces public or internal members automatically public abstract abstract methods abstract properties abstract indexers abstract events (later) public interface IGroupList : IEnumerable { } int Count { get; set } // abstract Property IClassList this[int index]; // abstract Indexer int Find(string name); // abstrac Method void remove(int index); void add(person p); (c)schmiedecke 13 C#-3-OO 62

63 Adapter: your travelagency software was using an old routing library you want to move on to a modern open-source version expose the requirements of your software as an interface write an Adapter class to implement the interface with the new library class Adapter class Adapter Trav elagency OldRouting Trav elagency IOldRouting + computeroute() : string[] + computeroute() : string[] RoutingAdadpter NewRouting + getruotings() : Route[] IOldRouting routing = new RoutingAdapter(); routing.computeroute(destinatiolist); (c)schmiedecke 13 C#-3-OO 63

64 Why didtravelagency not use an interface (IOldRouting) from the beginning? less dependant on the OldRoutingClass Dependency complicates change DIP: Program against interfaces to reduce dependency Always design interfaces for your classes! IList<Route> routelist = new LinkedList<Route>(); // very easy to change to ArrayList or another implementation // very easy to use a verbose debugging type instead during // implementation (c)schmiedecke 13 C#-3-OO 64

65 Proxy a client class refers to a "costly" object e.g. an image which needs downloading resources as long as the object is not really used, a mockup will do: Proxy when needed, the mockup will "secretly" get the object and delegate access. class Adapter class Adapter Photov iiewe Image Photov iiewe IImage + displayimage() : void + displayimage() : void ImageProxy + displayimage() : void Image + displaimage() : void class ImageProxy : IImage { void displayimage() { // download image when called Image img = loadimage(); img.displayimage(); } } (c)schmiedecke 13 C#-3-OO 65

66 These "Tricks" are well-known Design Patterns Every software professional must know them Good solutions to frequent problems Well-knowns structures improve code readability Original List by Gamma, Helm, Johnson and Vlissides Called Gang of Four Patterns or GoF Patterns (c)schmiedecke 13 C#-3-OO 66

67 Just like in Java A class can only inherit from ONE superclass but implement any number of Interfaces some Interfaces are empty "marker interfaces" test for type possible: mylist is ISerializable Interface IEnmuerable { Enumerator getenumerator(); } Interface IEnumerable<T> : IEnumerable { Enumerator<T> get Enumerator(); // addtional method } Interface ISerializable {} // empty marker interface class RandomEnumerator : IEnumerable<T>, ISerializable { } (c)schmiedecke 13 C#-3-OO 67

68 Interfaces are fully abstract Abstract classes are partly implemented specific methods open for implementation in subclasses Design Pattern: Template Method public abstract class Logger { string log; public void log(string logentry) { log += logentry } } public void closelog() { Save(); Clear(); } // template meth. abstract void Save(); public class FileLogger : Logger { public override void Save() { SendToFile(".\logfile.lg", log); } } (c)schmiedecke 13 C#-3-OO 68

69 In C#, not all methods areoverridden polymorphically. For Polymorphism: in the Superclass: Mark method as "virtual" in the Subclass Mark method as "override" Best Example: ToString() method public class Object { public virtual string ToString() { } } public class Appointment // : object { public override string ToString() { return this.name + ; } } (c)schmiedecke 13 C#-3-OO 69

70 Polymorphism, Dynamic Binding: method of instance type is called i.e. subclass method object appointment = new Appointment(); s = appointment.tostring(); // overridden ToString is called, i.e. as defined in the // Appointment class Static Binding method of the reference type (i.e.the variable) is called i.e. superclass method ( in this case, it would be the ToString-method in object. ) (c)schmiedecke 13 C#-3-OO 70

71 (c)schmiedecke 13 C#-3-OO 71

72 Historically: transforming input data to output data Waiting for the program to finish in order to get the result printout endless loops were desastrous. Today mainly: working interactively on complex information information only accessable via the program basically performing an endless loop waiting for user interaction Both need files to persist data while the program is not running. (c)schmiedecke 13 C#-3-OO 72

73 Streams are about getting data into a program out of a program Class Stream is abstract A Stream has a position current position end position Concrete Streams point to a Source/Destination FileStream NetworkStream MemoryStream (c)schmiedecke 13 C#-3-OO 73

74 Create a StreamObject Use it Close it!!! string filename ; Stream myfilestream = new FileStream(filename); myfilestream.writebyte('a'); myfilestream.close(); or use "auto closing" using (Stream myfilestream = new FileStream(filename)) { myfilestream.writebyte('a'); } (c)schmiedecke 13 C#-3-OO 74

75 BufferedStream don't forget to call Flush CryptoStream uses encryption! GzipStream Compressed source/destination Stream myfilestream = new FileStream(filename); GzipStream myzippedstream = new GzipStream(myFileStream); (c)schmiedecke 13 C#-3-OO 75

76 Abstract classes Reader and Writer specific direction much better functionality TextReader StreamReader StringReader TextWriter StreamWriter StringWriter StreamReader mystreamreader = new StreamReader(myFileStream); (c)schmiedecke 13 C#-3-OO 76

77 Writing binary data Class BinaryFormatter Can write numbers and other data i.e. any Object from a Serializable class Mark class as Serializble: [Serializable] or write your own Serialization by implementing ISerializable BinaryFormatter formatter = new BinaryFormatter(); try { myappointment = // save formatter.serialze(outputstream, myappointment); // modify myappointment = null; // restore myappointment = (Appointment)formatter.Deserialize(inputStream); } catch (IOException e) { Console.WriteLine("Persistence Failure"); } (c)schmiedecke 13 C#-3-OO 77

78 Exceptions are likely peripherical devices do fail at times catch IOExceptions!! Close your Streams! as long as it is open, it cannot be reused! use the using block with auto-closing! Binary Streams are illegible during development, work with Text Streams you can even edit the input files in the file system! (c)schmiedecke 13 C#-3-OO 78

79 Important data must "persist" (i.e. survive) between program newstarts Write the to files or to a Database Load Data on program start Save Data frequently during execution, to safeguard for program crashes e.g. wth every saving operation on memory (c)schmiedecke 13 C#-3-OO 79

80 C# is a powerful OO language with a powerful IDE for "visual" development Even in OO programming, it is all about Data in Value and Reference Types in Arrays in Basic and Generic Collections in Files and Databases as Input from a GUI Strong Types make Programming Safe but we need a lot of conversion techniques to remain flexible (c)schmiedecke 13 C#-3-OO 80

81 (c)schmiedecke 13 C#-3-OO 81

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

Computing is about Data Processing (or number crunching) Object Oriented Programming is about Cooperating Objects 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,

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

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

..to the Berlin BAU Software Lab! Let's have two interesting weeks together! (c)schmiedecke C# and.net

..to the Berlin BAU Software Lab! Let's have two interesting weeks together! (c)schmiedecke C# and.net ..to the Berlin BAU Software Lab! Let's have two interesting weeks together! (c)schmiedecke 13. 1 - C# and.net 2 Ilse Schmiedecke studied Computer Science in (West-)Berlin in the 70-ies married for more

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

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

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

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

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

COPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio

COPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio Introduction XXV Part I: C# Fundamentals 1 Chapter 1: The.NET Framework 3 What s the.net Framework? 3 Common Language Runtime 3.NET Framework Class Library 4 Assemblies and the Microsoft Intermediate Language

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

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

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

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

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

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

Course Hours

Course Hours Programming the.net Framework 4.0/4.5 with C# 5.0 Course 70240 40 Hours Microsoft's.NET Framework presents developers with unprecedented opportunities. From 'geoscalable' web applications to desktop and

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

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

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

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

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

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

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

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

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

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

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

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

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

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

WA1278 Introduction to Java Using Eclipse

WA1278 Introduction to Java Using Eclipse Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA1278 Introduction to Java Using Eclipse This course introduces the Java

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

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

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

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

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

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

Advanced Object-Oriented Programming. 11 Features. C# Programming: From Problem Analysis to Program Design. 4th Edition

Advanced Object-Oriented Programming. 11 Features. C# Programming: From Problem Analysis to Program Design. 4th Edition 11 Features Advanced Object-Oriented Programming C# Programming: From Problem Analysis to Program Design C# Programming: From Problem Analysis to Program Design 1 4th Edition Chapter Objectives Learn the

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

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 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

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

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

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

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

Prerequisites: The student should have programming experience in a high-level language. ITCourseware, LLC Page 1. Object-Oriented Programming in C#

Prerequisites: The student should have programming experience in a high-level language. ITCourseware, LLC Page 1. Object-Oriented Programming in C# Microsoft s.net is a revolutionary advance in programming technology that greatly simplifies application development and is a good match for the emerging paradigm of Web-based services, as opposed to proprietary

More information

Course Syllabus C # Course Title. Who should attend? Course Description

Course Syllabus C # Course Title. Who should attend? Course Description Course Title C # Course Description C # is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the.net Framework.

More information

CHAPTER 1: INTRODUCING C# 3

CHAPTER 1: INTRODUCING C# 3 INTRODUCTION xix PART I: THE OOP LANGUAGE CHAPTER 1: INTRODUCING C# 3 What Is the.net Framework? 4 What s in the.net Framework? 4 Writing Applications Using the.net Framework 5 What Is C#? 8 Applications

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

This tutorial has been prepared for the beginners to help them understand basics of c# Programming.

This tutorial has been prepared for the beginners to help them understand basics of c# Programming. About thetutorial C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its.net initiative led by Anders Hejlsberg. This tutorial covers basic C# programming

More information

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo Learning C# 3.0 Jesse Liberty and Brian MacDonald O'REILLY Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo Table of Contents Preface xv 1. C# and.net Programming 1 Installing C# Express 2 C# 3.0

More information

Introduction to Inheritance

Introduction to Inheritance Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#)

Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#) Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#) Course Number: 6367A Course Length: 3 Days Course Overview This three-day course will enable students to start designing

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

A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p.

A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p. A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p. 9 Classes and Objects p. 11 Creating Objects p. 12 Static or

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

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

(800) Toll Free (804) Fax   Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days Course Description This course introduces the Java programming language and how to develop Java applications using Eclipse 3.0. Students learn the syntax of the Java programming language, object-oriented

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

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

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

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com 70-483 MCSA Universal Windows Platform A Success Guide to Prepare- Programming in C# edusum.com Table of Contents Introduction to 70-483 Exam on Programming in C#... 2 Microsoft 70-483 Certification Details:...

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

C#: advanced object-oriented features

C#: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Namespaces

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Programming in Visual Basic with Microsoft Visual Studio 2010

Programming in Visual Basic with Microsoft Visual Studio 2010 Programming in Visual Basic with Microsoft Visual Studio 2010 Course 10550; 5 Days, Instructor-led Course Description This course teaches you Visual Basic language syntax, program structure, and implementation

More information

Software Development & Education Center. Java Platform, Standard Edition 7 (JSE 7)

Software Development & Education Center. Java Platform, Standard Edition 7 (JSE 7) Software Development & Education Center Java Platform, Standard Edition 7 (JSE 7) Detailed Curriculum Getting Started What Is the Java Technology? Primary Goals of the Java Technology The Java Virtual

More information

C#: advanced object-oriented features

C#: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Namespaces

More information

Classes. System. class String // alias for string

Classes. System. class String // alias for string Classes System class String // alias for string Length char this [] operator string + (string, string) operator == (string, string) operator!= (string, string) static string Empty static Compare (string,

More information

CHAPTER 1: INTRODUCTION TO THE IDE 3

CHAPTER 1: INTRODUCTION TO THE IDE 3 INTRODUCTION xxvii PART I: IDE CHAPTER 1: INTRODUCTION TO THE IDE 3 Introducing the IDE 3 Different IDE Appearances 4 IDE Configurations 5 Projects and Solutions 6 Starting the IDE 6 Creating a Project

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

DC69 C# and.net JUN 2015

DC69 C# and.net JUN 2015 Solutions Q.2 a. What are the benefits of.net strategy advanced by Microsoft? (6) Microsoft has advanced the.net strategy in order to provide a number of benefits to developers and users. Some of the major

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

DESIGN PATTERN - INTERVIEW QUESTIONS

DESIGN PATTERN - INTERVIEW QUESTIONS DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Agenda. Objects and classes Encapsulation and information hiding Documentation Packages

Agenda. Objects and classes Encapsulation and information hiding Documentation Packages Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics

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

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO 2010 Course: 10550A; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN This course teaches you

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

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

1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides

1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides 1B1b Inheritance Agenda Introduction to inheritance. How Java supports inheritance. Inheritance is a key feature of object-oriented oriented programming. 1 2 Inheritance Models the kind-of or specialisation-of

More information

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

Chapter 02 Building Multitier Programs with Classes

Chapter 02 Building Multitier Programs with Classes Chapter 02 Building Multitier Programs with Classes Student: 1. 5. A method in a derived class overrides a method in the base class with the same name. 2. 11. The Get procedure in a class module is used

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 7: Type Systems and Symbol Tables. CS 540 George Mason University

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing

More information

C# Programming in the.net Framework

C# Programming in the.net Framework 50150B - Version: 2.1 04 May 2018 C# Programming in the.net Framework C# Programming in the.net Framework 50150B - Version: 2.1 6 days Course Description: This six-day instructor-led course provides students

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

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

.NET-6Weeks Project Based Training

.NET-6Weeks Project Based Training .NET-6Weeks Project Based Training Core Topics 1. C# 2. MS.Net 3. ASP.NET 4. 1 Project MS.NET MS.NET Framework The.NET Framework - an Overview Architecture of.net Framework Types of Applications which

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

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

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have)

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have) Overview: Java programming language is developed by Sun Microsystems. Java is object oriented, platform independent, simple, secure, architectural neutral, portable, robust, multi-threaded, high performance,

More information