36
C# C# C C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } hello.cs C:\> csc hello.cs … … C:\> hello.exe Hello, World!

C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

  • View
    222

  • Download
    1

Embed Size (px)

Citation preview

Page 1: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

C#C# C#C#

CC

using System;public class MyClass } public static void Main() { Console.WriteLine("Hello, World!");}

}

using System;public class MyClass } public static void Main() { Console.WriteLine("Hello, World!");}

}

hello.cs

C:\> csc hello.cs… …C:\> hello.exeHello, World!

Page 2: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

2

Genealogy • Designer: Anders Hejlsberg (Microsoft)

– Designer of Turbo Pascal, Visual J++, Delphi (Borland)

• C Dynasty: Play on Words– C++ increment C by one.– C# the musical note half tone above C

• Yet another curly bracket programming language

– Grouping: {}– Terminstic camp: statements terminated by ";"– C operators: ++ % != += && & ^, >>, ?: …– C like control:

• if () … else … • for (…; …; …) … break … also multi-level break• while (…) … continue … also multi-level continue• do … while (…)• switch (…) … case … default no fall through, also switch on

strings

Page 3: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

3

Design Principles• All the Good Things:

– Simplicity, General Purpose, Portability, Object Oriented

• Programmer Protection:– Strong Nominative Typing– Array Bounds Checking– Garbage Collection – Check against using uninitialized variables– No "hiding" by inner scopes

• Evolutionary: dramatic changes in each language version

– Learn from Java mistakes: (no checked exceptions, since Anders Hejlsberg doesn't know yet how to do these right)

• Efficiency: Not at any price • Better Java?

– Developed by Microsoft– Compiles to the CLR "Common Language Interface"– Support for "unsafe" features, including pointers.

Page 4: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

4

Pre-Defined Types• Integral Types (signed and unsigned version)

: byte, sbyte, short, ushort, int, uint, long, ulong

•May cause conversion problems.•Most programmers like byte to be

unsigned.

•Real Numbers: float, double, decimal (28 digits)

•Other: bool, char (unicode), string (immutable unicode),

Page 5: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

5

Value/Reference Semantics•Value Types

– Simple types: char, int, float, …– Enum types

– Struct types

•Reference Types– Classes, Interfaces, Delegates

•Nullable Value Types

public enum Color {Red, Blue, Green }public enum Color {Red, Blue, Green }

public struct Point { public int x, y; }public struct Point { public int x, y; }

char? c = eof() ? null : getchar();if (c == null) …char c = c ?? ' ';

char? c = eof() ? null : getchar();if (c == null) …char c = c ?? ' ';

Page 6: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

6

Object Oriented Purity•Global Variables? No.

– All variables are defined in functions/classes.

•Global Routines? No.– All routines (functions) are defined in classes.

•Non OO Types? No.– Even primitive types belong in the OO hierarchy.

•OO Control Flow? No.– If, while, for, … are imperative statements

•Preprocessor? Yes. (a good preprocessor can be used to defeat any paradigm)

– Allows variables, but not parameterized macros.

Page 7: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

7

Inheritance Hierarchy• Classes:

– Single Inheritance– Common root: System.Object– Unified type system: includes all builtin types (except for void)

• System.ValueType:base class of all value types– Implementation by seamless auto-boxing and auto-unboxing.

• System.Enum: base class of all enum types• System.Array: base class of all arrays• …

– Unextendable classes: denoted by keyword sealed– Static classe: denoted by keyword static

• No non-static members• Must inherit form System.Object

• Interfaces:– Multiple Inheritance hierarchy– May be implemented by classes and structs

• Structs: no inheritance, but may implement interfaces.

Page 8: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

8

Reflection3 Levels: similar to Java and little-Smallatk

using System;using System.Reflection;

public static class FindLevels { private static void traverse(Object o) { for (int n = 0; ; o = o.GetType()) { Console.WriteLine(

"L"+ ++n + ": " + o + ".GetType() = " + o.GetType()); if (o == o.GetType()) break; } }

public static void Main() { traverse (3.1415926); }

}

using System;using System.Reflection;

public static class FindLevels { private static void traverse(Object o) { for (int n = 0; ; o = o.GetType()) { Console.WriteLine(

"L"+ ++n + ": " + o + ".GetType() = " + o.GetType()); if (o == o.GetType()) break; } }

public static void Main() { traverse (3.1415926); }

}

L1: 3.1415926.GetType() = System.DoubleL2: System.Double.GetType() = System.RuntimeTypeL3: System.RuntimeType.GetType() = System.RuntimeType

Page 9: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

9

Exploring Hierarchy with Reflection

using System;using System.Reflection;

public static class FindSuperTypes { private static String pName(Type t) { return t.BaseType == null ? "null" : t.BaseType.ToString(); }

private static void ancestory(Object o) { for (Type t = o.GetType(); t != null ; t = t.BaseType) Console.WriteLine(t + " inherits from " + pName(t)); }

public static void Main() { ancestory(3.1415926.GetType()); }}

using System;using System.Reflection;

public static class FindSuperTypes { private static String pName(Type t) { return t.BaseType == null ? "null" : t.BaseType.ToString(); }

private static void ancestory(Object o) { for (Type t = o.GetType(); t != null ; t = t.BaseType) Console.WriteLine(t + " inherits from " + pName(t)); }

public static void Main() { ancestory(3.1415926.GetType()); }}

System.RuntimeType inherits from System.TypeSystem.Type inherits from System.Reflection.MemberInfoSystem.Reflection.MemberInfo inherits from System.ObjectSystem.Object inherits from null

Page 10: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

10

Covariance• Suppose B is a

subtype of A: then an array of B is a subtype of an array of A.

Like Java, unlike C++.

• Runtime type checking: in assignments to array elements.

• No Array Covariance of Value types. Object a[] = new int[5]; // error

• Method arguments and return type are no-variant.

class A{};

void f(A[] a) {

a[0] = new A();//OK?}

class B: A {}

// Legal assignment

A[] x = new B[];

// Legal call

f(x);

Page 11: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

11

A Universal Dump Array Function

class EM: ICloneable { // Will dump any array thanks to array co-variancepublic static void print(

String title, Object[] array) {

if (array.Length == 0) return; Console.WriteLine(title + ":"); foreach (Object item in array) Console.WriteLine(" " + item); Console.WriteLine(); } // No co-variance of return type of methods public Object Clone() { return new EM();

} …}

class EM: ICloneable { // Will dump any array thanks to array co-variancepublic static void print(

String title, Object[] array) {

if (array.Length == 0) return; Console.WriteLine(title + ":"); foreach (Object item in array) Console.WriteLine(" " + item); Console.WriteLine(); } // No co-variance of return type of methods public Object Clone() { return new EM();

} …}

Page 12: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

12

Accessibility•Five Levels

– public Unlimited access– protected This class and all subclasses– internal Classes define in this "assembly"– protected internal This assembly and subclasses

• Nicknamed internal public – private This class only

•Default Levels– namespace public – enum public– class private– interface public– struct private– others internal

Page 13: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

13

Class/Struct Member Kinds• Instance Constructors: similar to C++/Java

constructors– Dynamic binding within constructors

• Finalizer: Syntax as C++ destructor; semantics as Java finalizer.

• Static Constructors: similar to Java static initiliazers• Constants: value computed at compile time

– implicitly static• Instance Fields: like Java/C++• Instance Readonly Fields: with readonly keyword

– initialized by constructor / static constructor• Static Fields: with static keyword• Static Readonly Fields: Initialized by static

constructor only• Methods & Static Methods: like Java/C++• Properties (and static properties): field access

implemented by methods • Indexers: array access implemented by methods• Events (and Static Events): more on these later

Page 14: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

14

Investigating Member Kinds

public class EM: ICloneable { public static void print(…) { … } public Object Clone() { … } static readonly public String NL = "\n"; public static void Main() { Type t = new EM().GetType(); Console.WriteLine(t+": "+t.Attributes + NL); print("Constructors", t.GetConstructors()); print("Methods", t.GetMethods()); print("Properties", t.GetProperties()); print("Fields", t.GetFields()); print("Events", t.GetEvents()); print("Interfaces", t.GetInterfaces()); }{

public class EM: ICloneable { public static void print(…) { … } public Object Clone() { … } static readonly public String NL = "\n"; public static void Main() { Type t = new EM().GetType(); Console.WriteLine(t+": "+t.Attributes + NL); print("Constructors", t.GetConstructors()); print("Methods", t.GetMethods()); print("Properties", t.GetProperties()); print("Fields", t.GetFields()); print("Events", t.GetEvents()); print("Interfaces", t.GetInterfaces()); }{

Page 15: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

15

Reflection Information

EM: AutoLayout, AnsiClass, Class, Public, BeforeFieldInitConstructors: Void .ctor()Methods: Void print(System.String, System.Object[]) System.Object Clone() Void Main() System.Type GetType() System.String ToString() Boolean Equals(System.Object) Int32 GetHashCode()Fields: System.String NLInterfaces: System.ICloneable

Page 16: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

16

Properties

public struct Window { public int n_read = 0; private string title; public string Title { // read-write property get { // property getter method n_read++; return title; } set { // property setter method if (title != value)// implicit parameter return; title = value; redraw(); } }…{

public struct Window { public int n_read = 0; private string title; public string Title { // read-write property get { // property getter method n_read++; return title; } set { // property setter method if (title != value)// implicit parameter return; title = value; redraw(); } }…{

• Property: a field implemented with methods• Varieties: read only, write only, read-write• Contextual keywords: get, set, value (also add and del for events)

– Provide specific meaning in the code– Not reserved words

Window w = new Window("Initial Title");Console.WriteLine(w.Title);// increment n_readw.Title = "My Title"; // redraw

Window w = new Window("Initial Title");Console.WriteLine(w.Title);// increment n_readw.Title = "My Title"; // redraw

Page 17: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

17

Static Properties

public struct HarryPotterBook { static private int count; static HarryPotterBook() {// static constructorcount = she_wrote_it() ? 7 : 6;

} static public int Count { // read-only static property get { return count; } }…{

public struct HarryPotterBook { static private int count; static HarryPotterBook() {// static constructorcount = she_wrote_it() ? 7 : 6;

} static public int Count { // read-only static property get { return count; } }…{

Page 18: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

18

Static Members•A Node With a Static Allocator

•A List Using the Static Allocator

class Node { public Node Next; public String Key; public Object Data; public Node(Node next) : this(null, null, next) { } public Node(String key, Object data, Node next) { Key = key; Data = data; Next = next; } static public Node Allocate(uint n) { return n == 0 ? null : new Node(Allocate(n - 1)); }}

class Node { public Node Next; public String Key; public Object Data; public Node(Node next) : this(null, null, next) { } public Node(String key, Object data, Node next) { Key = key; Data = data; Next = next; } static public Node Allocate(uint n) { return n == 0 ? null : new Node(Allocate(n - 1)); }}

class List { private Node first; public List(uint n) { first = Node.Allocate(n); } …{

class List { private Node first; public List(uint n) { first = Node.Allocate(n); } …{

Page 19: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

19

Indexers• Purpose: Implement array access with methods• Similar to properties (though no static indexers)

– Syntax: modifiers returnType this[IndexType pos]– Variations:

• multi-parameters indexers • read-only, write-only and read-write indexers• overloaded indexers

class List { … private Node nth(Node n, uint d) { if (n == null) throw new Exception("out of range"); return d == 0 ? n : nth(n.Next,d-1); } public Object this[uint i] { // indexer using ordinal position get { return nth(first, i).Data; } set { nth(first,i).Data = value; } } …}

class List { … private Node nth(Node n, uint d) { if (n == null) throw new Exception("out of range"); return d == 0 ? n : nth(n.Next,d-1); } public Object this[uint i] { // indexer using ordinal position get { return nth(first, i).Data; } set { nth(first,i).Data = value; } } …}

Page 20: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

20

Using the Indexerclass List { static void Main() { const uint n = 5; List sq = new List(n); for (uint i = 0; i < n; i++) sq[i] = i * i; for (uint i = 0; i < n; i++) Console.WriteLine(i + "^2 = " + sq[i]); }}

class List { static void Main() { const uint n = 5; List sq = new List(n); for (uint i = 0; i < n; i++) sq[i] = i * i; for (uint i = 0; i < n; i++) Console.WriteLine(i + "^2 = " + sq[i]); }} 0^2 = 0

1^2 = 12^2 = 43^2 = 9

4^2 = 16

Page 21: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

21

Indexer Overloadingpublic class List { … private static Node find(Node n, String k) { if (n == null) return null; return n.Key.Equals(k) ? n : find(n.Next,k); } public Object this[String k] { // indexer using key get { Node n = find(first, k); return n != null ? n.Data : null; } set { Node n = find(first, k); if (n != null) n.Data = value; else first = new Node(k, value, first); } }}

Page 22: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

22

Using String Indexer

class List { static void Main() { … List capitals = new List(0); capitals["Israel"] = "Jerusaelm"; capitals["Iraq"] = "Bagdad"; Console.WriteLine(capitals["Israel"]); }}

class List { static void Main() { … List capitals = new List(0); capitals["Israel"] = "Jerusaelm"; capitals["Iraq"] = "Bagdad"; Console.WriteLine(capitals["Israel"]); }}

Jerusalem

Page 23: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

23

Inheritance and Binding•Method Binding: static, unless method is

declared virtual– virtual modifier cannot go with any of static, abstract, private or override modifiers.

– Properties can be virtual

•Overriding: inheritance is strict by default.– Overriding methods must be declared as such with override keyword

– Cannot override non-virtual functions– Use new modifier to indicate hiding

•Sealing: use sealed keyword to indicate that an overriding function cannot be overridden further

– No point in sealing a "plain" virtual function.

Page 24: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

24

Events and Delegates• C# Terminology

– Event: a field representing a multi-set of delegates• Defined with event keyword• Operations

– Add delegate using += operator += has default implementation, but user can provide his own add.

– Remove delegate using -= operator-= has a default implementation, but user can provide his own del.

– Call all delegates in the multi-set– Delegate: type safe function pointer

• defined with delegate keyword • part of the class hierarchy

• Classical Example: when a button is pressed, listeners should be notified with "callback functions"

• Our Example: royal social conduct– If King is happy: notify all men in the kingdom– If King is ill: notify noblemen only.

Page 25: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

25

Kingdomnamespace

King, Nobleman and Citizens

Manabstract

Citizensealed

Noblemanconcrete

Kingconcrete

Lifestatic

• Name: every man has a name• Title: every man has a title, based on his status and

name– Realized by method ToString()

• Service: every man can be set to service any number of kings.

– Method service(King k) in class Person

Stateenum

Notify delegat

e

Page 26: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

26

Delegate Notify• Type Definition: pointer to a function (to be called when a

king changes his state)namespace Kingdom {

delegate Object Notify(King k); …

}• Simple (uninteresting) use: void foo() {

Notify bar; // A variable of type Notifybar = new Notify(FunctionDescriptor);…Object o = bar(); // Invoke FunctionDescriptor

}• More interesting use: class Foo {

event Notify baz; // A multi-set of variables of type Notifypublic void foo() {

baz += new Notify(FunctionDescriptor);…Object o = baz(); // Invoke FunctionDescriptor

}}

Notify delegat

e

Page 27: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

27

Class King and Enum Statenamespace Kingdom {…enum State { happy, ill };class King : Man { public State s; public King(String name): base(name){ s = State.ill; } sealed override public String ToString() { return "His Majesty, King " + Name; } // public multi-sets of those interested in the King's being. public event Notify when_ill, when_happy; public Object become_ill() { // returns last listener return value state = State.ill; return when_ill != null ? when_ill(this) : null; } public void become_happy() { // returns last listener return value

state = State.happy; return when_happy != null ? when_happy(this) : null; } } …}

Stateenum

Kingconcrete

Page 28: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

28

Class Mannamespace Kingdom { abstract class Man { protected readonly String Name; public Man(String name) { Name = name; } abstract override public String ToString(); // Every man is happy when a King he serves is happy. virtual public void serve(King k) { k.when_happy += new Notify(happy); } public void happy(Object other) { Console.WriteLine(this + " is happy to hear that " + other + " is happy."); } { ...}

Manabstract

Page 29: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

29

Delegates and Events•Delegate type definition: pointer to a

function (to be called when a king changes his state)namespace Kingdom { delegate Object Notify(King k); …

}

•Event definition: a field with a multi-set of delegates namespace Kingdom {class King: Man { public event Notify

when_ill, when_happy; …

}

It is possible (but not very useful) to define a field which contains a single delegate.

class KING: King { public Notify queen_listner;}

Page 30: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

30

Registration of an Actual Delegate• Actual Delegate: a function for notification

namespace Kingdom {…abstract class Man { public Man happy(Object other) { Console.WriteLine(this + " is happy to hear that " + other + " is happy.");

return this; } }…

}…

• Register a delegate: with += operatornamespace Kingdom {

abstract class Man { virtual public void serve(King k) {

k.when_happy += new Notify(happy); }

}}

Page 31: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

31

Classes Citizen and Noblemannamespace Kingdom {…sealed class Citizen: Man { public Citizen(String name) : base(name) { } override public String ToString() { return "Citizen " + Name; }}class Nobleman: Man { public Nobleman(String name) : base(name) { } override public String title() {return Name; } public Nobleman ill(Object other) { Console.WriteLine(this + " is sorry to hear that " + other + " is ill.");

return this; } override public void serve(King k) { base.serve(k); k.when_ill += new Notify(ill); } }{

Citizensealed

Noblemanconcrete

Page 32: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

32

static class Life { static void Main() { King R = new King("Richard"), G = new King("George"); Citizen a = new Citizen("Al"), b = new Citizen("Bob"); Nobleman v = new Nobleman("Virgil"); a.serve(R); b.serve(R); b.serve(G); v.serve(R); G.serve(R);

R.ill(); R.become_happy(); Console.WriteLine("----"); G.become_ill(); G.become_happy(); Console.WriteLine("----"); } }

Main Application

Al

Bob

Virgil

Richard Georg

e

Lifestatic

Page 33: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

33

Output

Virgil is sorry to hear that His Majesty, King Richard is ill.

Citizen Al is happy to hear that His Majesty, King Richard is happy.

Citizen Bob is happy to hear that His Majesty, King Richard is happy.

Virgil is happy to hear that His Majesty, King Richard is happy.

His Majesty, King George is happy to hear that His Majesty, King Richard is happy.

----

Citizen Bob is happy to hear that His Majesty, King George is happy.

----

Scenario

1. King Richard becomes ill

2. King Richard becomes happy

3. King George becomes happy

Remember, every man is happy when a king he serves is happy, but only a Noblemen is to be notified when his king is ill.

Al

Bob

Virgil

Richard Georg

e

Page 34: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

34

Delegate Variance• Delegate definition:delegate Object Notify(King k);

• Actual delegates: public Man happy(Object other) {…}public Nobleman ill(Object other){…}

• Variance:– Return Type: Co-Variant– Arguments Type: Contra-Variant– Static / Non-static: both static and non-static actuals may be used.

• Compatibility Rules: Allow a specific listener to subscribe to a more general event distribution channel

– It is OK to pass an actual King argument to the listener happy(Object other)

– Event triggering expects an Object, and is type safe even if a Man or a Nobleman is returned.

Page 35: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

35

Delegate Type Hierarchyusing System;using System.Reflection;

delegate Object MyDelegateType(Type o);

public static class DelegateTypeHierarchy { private static String pName(Type t) { as before... }

private static void ancestory(Object o){ as before… }

public static void Main() { ancestory(new MyDelegateType(pName)); }

}

using System;using System.Reflection;

delegate Object MyDelegateType(Type o);

public static class DelegateTypeHierarchy { private static String pName(Type t) { as before... }

private static void ancestory(Object o){ as before… }

public static void Main() { ancestory(new MyDelegateType(pName)); }

}

MyDelegateType inherits from System.MulticastDelegateSystem.MulticastDelegate inherits from System.DelegateSystem.Delegate inherits from System.ObjectSystem.Object inherits from null

Page 36: C#C# C using System; public class MyClass } public static void Main() { Console.WriteLine("Hello, World!"); } } using System; public class MyClass } public

36

Summary – C# Unique Features

•Properties and Indexers: implement fields with functions– Conforms to Eiffel Principle of Uniform Reference.

•Delegates: type safe function pointers– Events: list of delegates.

•Static classes•Seamless integration of value semantics– Including nullable values.

•Default Strict Inheritance– override and new keywords