JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Java interview questions part 6
Java interview questions part 6
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. Which method is used to create a directory with fileattributes?
A. Path.create()
B. Path.createDirectory()
C. Files.createDirectory(path, fileAttributes)
D. Files.create(fileAttributes)
Show Correct Answer
Correct Answer is :
Files.createDirectory(path, fileAttributes)
2. Which method can be used to check fileAccessiblity?
A. isReadable(path)
B. isWritable(path)
C. isExecutable(path)
D. isReadable(path), isWritable(path), and isExecutable(path)
Show Correct Answer
Correct Answer is :
isReadable(path), isWritable(path), and isExecutable(path)
3. How can we delete all files in a directory?
A. Files.delete(path)
B. Files.deleteDir()
C. Directory.delete()
D. Directory.delete(path)
Show Correct Answer
Correct Answer is :
Files.delete(path)
4. How to copy the file from one location to other?
A. Files.copy(source, target)
B. Path.copy(source, target)
C. source.copy(target)
D. Files.createCopy(target)
Show Correct Answer
Correct Answer is :
Files.copy(source, target)
5. How can we get the size of specified file?
A. capacity(path)
B. size(path)
C. length(path)
D. Path.size()
Show Correct Answer
Correct Answer is :
size(path)
6. How to read entire file in one line using java 8?
A. Files.readAllLines()
B. Files.read()
C. Files.readFile()
D. Files.lines()
Show Correct Answer
Correct Answer is :
Files.readAllLines()
7. How can we create a symbolic link to file?
A. createLink()
B. createSymLink()
C. createSymbolicLink()
D. createTempLink()
Show Correct Answer
Correct Answer is :
createSymbolicLink()
8. How can we filter lines based on content?
A. lines.filter()
B. filter(lines)
C. lines.contains(filter)
D. lines.select()
Show Correct Answer
Correct Answer is :
lines.filter()
9. Which jar provides FileUtils which contains methods for file operations?
A. file
B. apache commons
C. file commons
D. dir
Show Correct Answer
Correct Answer is :
apache commons
10. Which feature of java 7 allows to not explicitly close IO resource?
A. try catch finally
B. IOException
C. AutoCloseable
D. Streams
Show Correct Answer
Correct Answer is :
AutoCloseable
11. Which of the following is not introduced with Java 8?
A. Stream API
B. Serialization
C. Spliterator
D. Lambda Expression
Show Correct Answer
Correct Answer is :
Serialization
12. What is the purpose of BooleanSupplier function interface?
A. represents supplier of Boolean-valued results
B. returns Boolean-valued result
C. There is no such function interface
D. returns null if Boolean is passed as argument
Show Correct Answer
Correct Answer is :
represents supplier of Boolean-valued results
13. What is the return type of lambda expression?
A. String
B. Object
C. void
D. Function
Show Correct Answer
Correct Answer is :
Function
14. Which is the new method introduced in java 8 to iterate over a collection?
A. for (String i : StringList)
B. foreach (String i : StringList)
C. StringList.forEach()
D. List.for()
Show Correct Answer
Correct Answer is :
StringList.forEach()
15. What are the two types of Streams offered by java 8?
A. sequential and parallel
B. sequential and random
C. parallel and random
D. random and synchronized
Show Correct Answer
Correct Answer is :
sequential and parallel
16. Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target?
A. workPool
B. newWorkStealingPool
C. threadPool
D. workThreadPool
Show Correct Answer
Correct Answer is :
newWorkStealingPool
17. What does Files.lines(Path path) do?
A. It reads all the files at the path specified as a String
B. It reads all the lines from a file as a Stream
C. It reads the filenames at the path specified
D. It counts the number of lines for files at the path specified
Show Correct Answer
Correct Answer is :
It reads all the lines from a file as a Stream
18. What is Optional object used for?
A. Optional is used for optional runtime argument
B. Optional is used for optional spring profile
C. Optional is used to represent null with absent value
D. Optional means it’s not mandatory for method to return object
Show Correct Answer
Correct Answer is :
Optional is used to represent null with absent value
19. What is the substitute of Rhino javascript engine in Java 8?
A. Nashorn
B. V8
C. Inscript
D. Narcissus
Show Correct Answer
Correct Answer is :
Nashorn
20. What does SAM stand for in the context of Functional Interface?
A. Single Ambivalue Method
B. Single Abstract Method
C. Simple Active Markup
D. Simple Abstract Markup
Show Correct Answer
Correct Answer is :
Single Abstract Method
Similar Interview Questions
Search for latest jobs
Find Jobs