Skip to content

Instantly share code, notes, and snippets.

@rozer007
Created December 15, 2021 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozer007/a03c0b4e7f70790ce3c825f77ac85a65 to your computer and use it in GitHub Desktop.
Save rozer007/a03c0b4e7f70790ce3c825f77ac85a65 to your computer and use it in GitHub Desktop.
Enums, Structs and Abstract Type in julia
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.
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