COOP at ETHZ - ETH Zurich | Flashcards & Summaries

Select your language

Suggested languages for you:
Log In Start studying!

Lernmaterialien für COOP an der ETHZ - ETH Zurich

Greife auf kostenlose Karteikarten, Zusammenfassungen, Übungsaufgaben und Altklausuren für deinen COOP Kurs an der ETHZ - ETH Zurich zu.

TESTE DEIN WISSEN

Which languages are statically safe?

Lösung anzeigen
TESTE DEIN WISSEN

Java


Lösung ausblenden
TESTE DEIN WISSEN

Whats the difference between an untyped, weakly typed or strongly typed language?

Lösung anzeigen
TESTE DEIN WISSEN

In an untyped language you don't classify bits into bools, arrays, and so on.

In a weakly typed language you do give things types but you allow them to be cast at runtime. So you can suddenly interpret a list of strings as a list of ints.

Strongly typed languages give compile or runtime errors if you try to do something with a type that can't be done.

Lösung ausblenden
TESTE DEIN WISSEN

Which of these languages are weakly typed?

Lösung anzeigen
TESTE DEIN WISSEN

Assembly

Lösung ausblenden
TESTE DEIN WISSEN

Which languages are strongly typed?

Lösung anzeigen
TESTE DEIN WISSEN

Almost all languages today

Lösung ausblenden
TESTE DEIN WISSEN

What is static vs dynamic type checking?

Lösung anzeigen
TESTE DEIN WISSEN

Static means that the types must be clear at compile time - wrong usage gives a compile error.

In every execution state, the value held by variable is an element of the declared type of v


Dynamic means that a variable can change its type during the execution of the program. So wrong usage gives a runtime error.

Lösung ausblenden
TESTE DEIN WISSEN

Advantages of static type checking?

Lösung anzeigen
TESTE DEIN WISSEN

Static safety (more errors found at runtime)

Lösung ausblenden
TESTE DEIN WISSEN

What does it mean that the subtypes interface must be wider?

Lösung anzeigen
TESTE DEIN WISSEN

That it must have all the methods of the parent.

That all the methods of the parent need to be at least as accessible (so you can't change a public method to a private but the other way around you can)

That all the parameters of the child methods must be the same types or parent types. (can't have a parameter change from object to string but the other way around you can). This is called contravariant parameters.

Lösung ausblenden
TESTE DEIN WISSEN

What does contravariant and covariant mean?

Lösung anzeigen
TESTE DEIN WISSEN

Covariant means that it must be a parent type and contravariant that it must be a child type.

Lösung ausblenden
TESTE DEIN WISSEN

What is the inheritance rule for preconditions?


Lösung anzeigen
TESTE DEIN WISSEN

That subtypes precondition is the disjunct (logical or) of all inherited and declared preconditions.

So all the preconditions from the supertypes and the ones from the subtype itself are or'ed to yield the effective precondition for the subtype.

Lösung ausblenden
TESTE DEIN WISSEN

​Whats the easy to remember rules for behavioral subtyping?

Lösung anzeigen
TESTE DEIN WISSEN

Subtypes must fulfill the contracts of the supertypes and if they want they can make them stronger (which means preconditions can be made weaker)

Lösung ausblenden
TESTE DEIN WISSEN

What are 3 rules for maintaining robust inheritance (making sure subclasses don't break)?

Lösung anzeigen
TESTE DEIN WISSEN
  1. When writing a subclass using inheritance, rely on interface documentation, not on implementation
  2. When writing a subclass override all methods that could break invariants
  3. When writing a superclass don't change calls to dynamically-bound methods (that means methods that a superclass could override)
Lösung ausblenden
TESTE DEIN WISSEN

What is the difference between a statically and a dynamically typed language?

Lösung anzeigen
TESTE DEIN WISSEN

Statically means at compile time and dynamically at runtime.

Lösung ausblenden
  • 96766 Karteikarten
  • 1723 Studierende
  • 87 Lernmaterialien

Beispielhafte Karteikarten für deinen COOP Kurs an der ETHZ - ETH Zurich - von Kommilitonen auf StudySmarter erstellt!

Q:

Which languages are statically safe?

A:

Java


Q:

Whats the difference between an untyped, weakly typed or strongly typed language?

A:

In an untyped language you don't classify bits into bools, arrays, and so on.

In a weakly typed language you do give things types but you allow them to be cast at runtime. So you can suddenly interpret a list of strings as a list of ints.

Strongly typed languages give compile or runtime errors if you try to do something with a type that can't be done.

Q:

Which of these languages are weakly typed?

A:

Assembly

Q:

Which languages are strongly typed?

A:

Almost all languages today

Q:

What is static vs dynamic type checking?

A:

Static means that the types must be clear at compile time - wrong usage gives a compile error.

In every execution state, the value held by variable is an element of the declared type of v


Dynamic means that a variable can change its type during the execution of the program. So wrong usage gives a runtime error.

Mehr Karteikarten anzeigen
Q:

Advantages of static type checking?

A:

Static safety (more errors found at runtime)

Q:

What does it mean that the subtypes interface must be wider?

A:

That it must have all the methods of the parent.

That all the methods of the parent need to be at least as accessible (so you can't change a public method to a private but the other way around you can)

That all the parameters of the child methods must be the same types or parent types. (can't have a parameter change from object to string but the other way around you can). This is called contravariant parameters.

Q:

What does contravariant and covariant mean?

A:

Covariant means that it must be a parent type and contravariant that it must be a child type.

Q:

What is the inheritance rule for preconditions?


A:

That subtypes precondition is the disjunct (logical or) of all inherited and declared preconditions.

So all the preconditions from the supertypes and the ones from the subtype itself are or'ed to yield the effective precondition for the subtype.

Q:

​Whats the easy to remember rules for behavioral subtyping?

A:

Subtypes must fulfill the contracts of the supertypes and if they want they can make them stronger (which means preconditions can be made weaker)

Q:

What are 3 rules for maintaining robust inheritance (making sure subclasses don't break)?

A:
  1. When writing a subclass using inheritance, rely on interface documentation, not on implementation
  2. When writing a subclass override all methods that could break invariants
  3. When writing a superclass don't change calls to dynamically-bound methods (that means methods that a superclass could override)
Q:

What is the difference between a statically and a dynamically typed language?

A:

Statically means at compile time and dynamically at runtime.

COOP

Erstelle und finde Lernmaterialien auf StudySmarter.

Greife kostenlos auf tausende geteilte Karteikarten, Zusammenfassungen, Altklausuren und mehr zu.

Jetzt loslegen

Das sind die beliebtesten StudySmarter Kurse für deinen Studiengang COOP an der ETHZ - ETH Zurich

Für deinen Studiengang COOP an der ETHZ - ETH Zurich gibt es bereits viele Kurse, die von deinen Kommilitonen auf StudySmarter erstellt wurden. Karteikarten, Zusammenfassungen, Altklausuren, Übungsaufgaben und mehr warten auf dich!

Das sind die beliebtesten COOP Kurse im gesamten StudySmarter Universum

OOP

Frankfurt University of Applied Sciences

Zum Kurs

Die all-in-one Lernapp für Studierende

Greife auf Millionen geteilter Lernmaterialien der StudySmarter Community zu
Kostenlos anmelden COOP
Erstelle Karteikarten und Zusammenfassungen mit den StudySmarter Tools
Kostenlos loslegen COOP