Skip to content

Instantly share code, notes, and snippets.

@rozer007
Created December 15, 2021 11:25
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/ae1697f6fb66b0f42695102c70ca552e to your computer and use it in GitHub Desktop.
Save rozer007/ae1697f6fb66b0f42695102c70ca552e to your computer and use it in GitHub Desktop.
File handling and Exception handling in julia
Q1.What is the function of chomp()?
ans: This function is use to remove the newline included while recieving input from the user.
Q2.Is there a finally block in julia?
ans: Yes there is a finally block in julia just like other languages.
Q3.To write a file in what mode does the file has to be opened?
ans: It can we open many ways : append mode,write mode,read write mode etc.
Q4.What does the readline function do?
ans: The readline function read the file line by line.
Q1.what does a try block do?
a) execute an expression
b) catch exception
c) check for exception
d) none of the above
ans: c)
Q2.
open("file_name.txt") do ft
println(read(ft,String))
end
What will be return by the read function in the above statements:
a) all the content
b) a string containing all the content
c) one line of the file
d) none of the above
ans: b)
Q3. try
println(2/0)
catch err
println("Err")
end
In the above statement is the exception handle or not.
a) yes
b) No
c) Undefined
ans: b)
Q4. What will the output of this statements:
open("file_name.txt","w") do ft
write(ft,"The kraken\n")
write(ft,"Gomu Gomu no\n")
write(ft,"peira fururu\n")
end
open("file_name.txt") do ft
str=read(ft,String)
println(str[2:8])
end
a) The kraken
b) mu Gomu
c) he Krak
d) None of the above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment