Created
December 15, 2021 11:04
-
-
Save rozer007/a03c0b4e7f70790ce3c825f77ac85a65 to your computer and use it in GitHub Desktop.
Enums, Structs and Abstract Type in julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1.How do we define enumeration in julia? | |
ans: We will use the enum keyword to define a enumerate in julia. | |
Q2.How can we access the fields of an enum? | |
ans: we should use :: operator to access the field in an enum. | |
Q3.How to create an object for a structure? | |
ans: varname= structure_name(parameter) , this is the syntax for creating an object of a structure. | |
Q4.What is the use of abstract types in julia? | |
ans:It allow the construction of a heirarchy of types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1. What operator is use to inherit a abstract type from a structure: | |
a) < | |
b) > | |
c) <: | |
d) >: | |
ans: c) | |
Q2.What will be the output of the statements: | |
@enum xom begin | |
z=10+1 | |
f=9%2 | |
end | |
println(z::xom) | |
a) Error | |
b) 1 | |
c) 11 | |
d) z | |
ans: d) | |
Q3) What will be the output in this statements: | |
struct x | |
a | |
b | |
end | |
xr=x(1,2) | |
println(xr) | |
a) 1,2 | |
b) (1,2) | |
c) x(1,2) | |
d) xr(1,2) | |
ans: c) | |
Q4.What is the correct way to create an abstract type? | |
a) abstract name | |
b) abstract class name | |
c) abstract class name end | |
d) None of the above | |
ans: c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment