Greife auf kostenlose Karteikarten, Zusammenfassungen, Übungsaufgaben und Altklausuren für deinen COOP Kurs an der ETHZ - ETH Zurich zu.
Which languages are statically safe?
Java
Whats the difference between an untyped, weakly typed or strongly typed language?
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.
Which of these languages are weakly typed?
Assembly
Which languages are strongly typed?
Almost all languages today
What is static vs dynamic type checking?
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.
Advantages of static type checking?
Static safety (more errors found at runtime)
What does it mean that the subtypes interface must be wider?
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.
What does contravariant and covariant mean?
Covariant means that it must be a parent type and contravariant that it must be a child type.
What is the inheritance rule for preconditions?
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.
Whats the easy to remember rules for behavioral subtyping?
Subtypes must fulfill the contracts of the supertypes and if they want they can make them stronger (which means preconditions can be made weaker)
What are 3 rules for maintaining robust inheritance (making sure subclasses don't break)?
What is the difference between a statically and a dynamically typed language?
Statically means at compile time and dynamically at runtime.
Greife kostenlos auf tausende geteilte Karteikarten, Zusammenfassungen, Altklausuren und mehr zu.
Jetzt loslegenFü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!