Practice high-yield Programming & Software Development MCQs on Java Autoboxing — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the two types of Streams offered by java 8?
Correct Answer: Option A — sequential and parallel
Detailed Academic Explanation:
sequential and parallel is the correct answer to “What are the two types of Streams offered by java 8”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target?
Correct Answer: Option B — newWorkStealingPool
Detailed Academic Explanation:
newWorkStealingPool is the correct answer to “Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does Files.lines(Path path) do?
Correct Answer: Option B — It reads all the lines from a file as a Stream
Detailed Academic Explanation:
It reads all the lines from a file as a Stream is the correct answer to “What does Files.lines(Path path) do”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is Optional object used for?
Correct Answer: Option C — Optional is used to represent null with absent value
Detailed Academic Explanation:
Optional is used to represent null with absent value is the correct answer to “What is Optional object used for”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the substitute of Rhino javascript engine in Java 8?
Correct Answer: Option A — Nashorn
Detailed Academic Explanation:
Nashorn is the correct answer to “What is the substitute of Rhino javascript engine in Java 8”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does SAM stand for in the context of Functional Interface?
Correct Answer: Option B — Single Abstract Method
Detailed Academic Explanation:
Single Abstract Method is the correct answer to “What does SAM stand for in the context of Functional Interface”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to create a directory with fileattributes?
Correct Answer: Option C — Files.createDirectory(path, fileAttributes)
Detailed Academic Explanation:
Files.createDirectory(path, fileAttributes) is the correct answer to “Which method is used to create a directory with fileattributes”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method can be used to check fileAccessiblity?
Correct Answer: Option D — isReadable(path), isWritable(path), and isExecutable(path)
Detailed Academic Explanation:
isReadable(path), isWritable(path), and isExecutable(path) is the correct answer to “Which method can be used to check fileAccessiblity”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can we delete all files in a directory?
Correct Answer: Option A — Files.delete(path)
Detailed Academic Explanation:
Files.delete(path) is the correct answer to “How can we delete all files in a directory”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How to copy the file from one location to other?
Correct Answer: Option A — Files.copy(source, target)
Detailed Academic Explanation:
Files.copy(source, target) is the correct answer to “How to copy the file from one location to other”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can we get the size of specified file?
Correct Answer: Option B — size(path)
Detailed Academic Explanation:
size(path) is the correct answer to “How can we get the size of specified file”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How to read entire file in one line using java 8?
Correct Answer: Option A — Files.readAllLines()
Detailed Academic Explanation:
Files.readAllLines() is the correct answer to “How to read entire file in one line using java 8”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can we create a symbolic link to file?
Correct Answer: Option C — createSymbolicLink()
Detailed Academic Explanation:
createSymbolicLink() is the correct answer to “How can we create a symbolic link to file”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can we filter lines based on content?
Correct Answer: Option A — lines.filter()
Detailed Academic Explanation:
lines.filter() is the correct answer to “How can we filter lines based on content”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which jar provides FileUtils which contains methods for file operations?
Correct Answer: Option B — apache commons
Detailed Academic Explanation:
apache commons is the correct answer to “Which jar provides FileUtils which contains methods for file operations”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which feature of java 7 allows to not explicitly close IO resource?
Correct Answer: Option C — AutoCloseable
Detailed Academic Explanation:
AutoCloseable is the correct answer to “Which feature of java 7 allows to not explicitly close IO resource”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a core interface of Hibernate?
Correct Answer: Option C — SessionManagement
Detailed Academic Explanation:
SessionManagement is the correct answer to “Which of the following is not a core interface of Hibernate”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
SessionFactory is a thread-safe object.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “SessionFactory is a thread-safe object.”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following methods returns proxy object?
Correct Answer: Option C — load()
Detailed Academic Explanation:
load() is the correct answer to “Which of the following methods returns proxy object”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following methods hits database always?
Correct Answer: Option D — get()
Detailed Academic Explanation:
get() is the correct answer to “Which of the following methods hits database always”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following method is used inside session only?
Correct Answer: Option B — update()
Detailed Academic Explanation:
update() is the correct answer to “Which of the following method is used inside session only”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a state of object in Hibernate?
Correct Answer: Option A — Attached()
Detailed Academic Explanation:
Attached() is the correct answer to “Which of the following is not a state of object in Hibernate”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not an inheritance mapping strategies?
Correct Answer: Option D — Table per class
Detailed Academic Explanation:
Table per class is the correct answer to “Which of the following is not an inheritance mapping strategies”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not an advantage of using Hibernate Query Language?
Correct Answer: Option D — Difficult to implement
Detailed Academic Explanation:
Difficult to implement is the correct answer to “Which of the following is not an advantage of using Hibernate Query Language”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In which file database table configuration is stored?
Correct Answer: Option B — .hbm
Detailed Academic Explanation:
.hbm is the correct answer to “In which file database table configuration is stored”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not an advantage of Hibernate Criteria API?
Correct Answer: Option B — Cannot order the result set
Detailed Academic Explanation:
Cannot order the result set is the correct answer to “Which of the following is not an advantage of Hibernate Criteria API”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does Liskov substitution principle specify?
Correct Answer: Option A — parent class can be substituted by child class
Detailed Academic Explanation:
parent class can be substituted by child class is the correct answer to “What does Liskov substitution principle specify”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the correct option of the following Java code snippet? interface ICust { } class RegularCustomer implements ICust { } class OneTimeCustomer implements ICust { }
Correct Answer: Option A — ICust can be replaced with RegularCustomer
Detailed Academic Explanation:
ICust can be replaced with RegularCustomer is the correct answer to “What will be the correct option of the following Java code snippet? interface ICust { } class RegularCustomer implements ICust { } class OneTimeCustomer implements ICust { }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code snippet? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Square square = new Square(); shape = square; System.out.println(shape.area()); } }
Correct Answer: Option D — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following Java code snippet? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Square square = new Square(); shape = square; System.out.println(shape.area()); } }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code snippet? public class Shape { public int area() { return 1; } } public class Rectangle extends Shape { public int area() { return 3; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Rectangle rect = new Rectangle(); shape = rect; System.out.println(shape.area()); } }
Correct Answer: Option B — 3
Detailed Academic Explanation:
3 is the correct answer to “What will be the output of the following Java code snippet? public class Shape { public int area() { return 1; } } public class Rectangle extends Shape { public int area() { return 3; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Rectangle rect = new Rectangle(); shape = rect; System.out.println(shape.area()); } }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Square square = new Square(); square = shape; System.out.println(square.area()); } }
Correct Answer: Option A — Compilation failure
Detailed Academic Explanation:
Compilation failure is the correct answer to “What will be the output of the following Java code? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Square square = new Square(); square = shape; System.out.println(square.area()); } }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } public class Rectangle extends Shape { public int area() { return 3; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Square square = new Square(); Rectangle rect = new Rectangle(); rect = (Rectangle)shape; System.out.println(square.area()); } }
Correct Answer: Option C — Runtime Exception
Detailed Academic Explanation:
Runtime Exception is the correct answer to “What will be the output of the following Java code? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } public class Rectangle extends Shape { public int area() { return 3; } } class Main() { public static void main(String[] args) { Shape shape = new Shape(); Square square = new Square(); Rectangle rect = new Rectangle(); rect = (Rectangle)shape; System.out.println(square.area()); } }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } public class Rectangle extends Shape { public int area() { return 3; } } public static void main(String[] args) { Shape shape = new Square(); shape = new Rectangle(); System.out.println(shape.area()); }
Correct Answer: Option B — 3
Detailed Academic Explanation:
3 is the correct answer to “What will be the output of the following Java code? public class Shape { public int area() { return 1; } } public class Square extends Shape { public int area() { return 2; } } public class Rectangle extends Shape { public int area() { return 3; } } public static void main(String[] args) { Shape shape = new Square(); shape = new Rectangle(); System.out.println(shape.area()); }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What should the return type of method where there is no return value?
Correct Answer: Option B — Empty collection
Detailed Academic Explanation:
Empty collection is the correct answer to “What should the return type of method where there is no return value”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What data structure should be used when number of elements is fixed?
Correct Answer: Option A — Array
Detailed Academic Explanation:
Array is the correct answer to “What data structure should be used when number of elements is fixed”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What causes the program to exit abruptly and hence its usage should be minimalistic?
Correct Answer: Option C — Exit
Detailed Academic Explanation:
Exit is the correct answer to “What causes the program to exit abruptly and hence its usage should be minimalistic”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is good coding practice to determine oddity? i) public boolen abc(int num) { return num % 2 == 1; } ii) public boolean xyz(int num) { return (num & 1)!= 0; }
Correct Answer: Option B — ii
Detailed Academic Explanation:
ii is the correct answer to “Which of the following is good coding practice to determine oddity? i) public boolen abc(int num) { return num % 2 == 1; } ii) public boolean xyz(int num) { return (num & 1)!= 0; }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following causes memory leak?
Correct Answer: Option D — Not using Finally block often
Detailed Academic Explanation:
Not using Finally block often is the correct answer to “Which one of the following causes memory leak”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a best practice to measure time taken by a process for execution?
Correct Answer: Option B — System.nanoTime()
Detailed Academic Explanation:
System.nanoTime() is the correct answer to “Which of the following is a best practice to measure time taken by a process for execution”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What one of the following is best practice to handle Null Pointer exception? i) int noOfStudents = line.listStudents().count; ii) int noOfStudents = getCountOfStudents(line); public int getCountOfStudents(List line) { if(line != null) { if(line.listOfStudents() != null) { return line.listOfStudents().size(); } } throw new NullPointerException("List is empty"); }
Correct Answer: Option B — Option (ii)
Detailed Academic Explanation:
Option (ii) is the correct answer to “What one of the following is best practice to handle Null Pointer exception? i) int noOfStudents = line.listStudents().count; ii) int noOfStudents = getCountOfStudents(line); public int getCountOfStudents(List line) { if(line != null) { if(line.listOfStudents() != null) { return line.listOfStudents().size(); } } throw new NullPointerException("List is empty"); }”. This question is standard in competitive examination syllabi for Java Autoboxing.
💡Key Conceptual Anchor:Java Autoboxing
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.