Quiz 1.9: Custom typesQ1: Type theoryWhich of the following sentences are correct ? After a Type has been defined, it can no longer be redefined Unless explicitly declared as mutable, composite types once created can no longer be modified Unless explicitly declared as mutable, variables assigned to an object of a composite type once assigned can no longer be reassigned to another object x = MyType(1,2,3) performs two operations: first it instantiates an object of type Mytype and then it assigns this object to the variable x Primitive types cannot be declared child of an abstract type Composite types cannot be declared child of an abstract type Objects can not be instantiated out of an abstract type None of the (other) sentences is correct RESOLUTIONPlease look again the corresponding segment for clarifications.The correct answers are:After a Type has been defined, it can no longer be redefinedUnless explicitly declared as mutable, composite types once created can no longer be modifiedx = MyType(1,2,3) performs two operations: first it instantiates an object of type Mytype and then it assigns this object to the variable xObjects can not be instantiated out of an abstract typeQ2: Type theory (2)Given the following code snippet:abstract type Aoo end struct Foo f1::Int64 f2::String endWhich of the following commands, taken individually, would raise an error? Foo(x,y) = Foo(y,x); Foo("aaa",1) o = Foo(f1=1,f2="aaa") o = Aoo() o = Foo(2,"bbb"); o.f1 +=1 o = Foo(1,"aaa") o = Foo(2,"bbb"); println(o.f1) RESOLUTIONConcerning the commands raising an error: (1) the default constructor takes only positional arguments (in the order the type has been defined); (2) it is not possible to instantiate objects from an abstract type; (3) it is not possible to modify an immutable objectThe correct answers are:o = Foo(f1=1,f2="aaa")o = Aoo()o = Foo(2,"bbb"); o.f1 +=1Q3: "Types" of typesGiven the following code snippet:struct Foo{T<:Number} f1::T f2::T endWhich properties are correct for Foo? Foo is mutable Foo is concrete Foo is composite Foo is parametric Foo{Int64} is a bits type Foo{Int64} is a child of Foo{Number} None of the (other) sentences is correct RESOLUTIONConcerning the wrong sentences: (1) Foo is immutable, as it has not explicitly been declared mutable,(2) A parent/child relation in the template parameter type (here Int64 being a child of Number) doesn't extend to an equivalent parent/child relation in the main parametric type. This has important consequences. If you want to define a function foo whose parameter x is a vector of numbers (integers, floats,...) rather than define your function as foo(x::Vector{Number}) use instead foo(x::Vector{T}) where {T<: Number}. Even better, use AbstractVector unless you really need to constrain the parameter to being a Vector.The correct answers are:Foo is concreteFoo is compositeFoo is parametricFoo{Int64} is a bits typeQ4: Constructor of a parametric typeGiven the following code snippet:struct Foo{T<:Number} f1::T f2::T function Foo(x::T,y::T) where {T<:Number} return XXXX(x,y) end endTo what XXXX should be replaced for the given inner constructor to work (don't use spaces)? RESOLUTIONInner constructors use the keyword new. In this case, because we are dealing with a parametric type, the correct syntax is new{T}(...arguments...)The correct answer is: new{T} « 0105q - QUIZ 1.100105x EXERCISE-1.1 »Powered by Documenter.jl and the Julia Programming Language.SettingsThemeAutomatic (OS)documenter-lightdocumenter-darkcatppuccin-lattecatppuccin-frappecatppuccin-macchiatocatppuccin-mochaThis document was generated with Documenter.jl version 1.19.0 on Wednesday 30 September 2026. Using Julia version 1.12.7.