Browse all practice questions for the Java FPT Software (Fsoft) Academy Practice Test. Search by topic, open any question and review its full explanation, then test yourself in the practice quiz.

Ace the Java Fsoft Academy Challenge 2026 – Code Your Way to Success! course image
More practice questions

These questions are part of the practice quiz. Start practicing

  • Which statement about interfaces best describes their role?
  • Which singleton pattern approach provides thread-safety with lazy initialization using the Initialization-on-demand Holder idiom?
  • Given a superclass with a constructor Dog(String name) and a subclass Beagle that defines only one constructor, which Beagle constructor would be legal?
  • When do Java static initialization blocks execute?
  • Which exception is typically caught for I/O operations in Java?
  • Which class declaration is valid in a Java file named Example.java?
  • Which statement will throw a NullPointerException when executed?
  • If b starts as 8 and c starts as 3, what is the value of b after performing b = (byte) (b ^ c)?
  • Which statement best describes inheritance in Java?
  • What is the difference between HashMap and ConcurrentHashMap?
  • Which Map implementation maintains keys in natural order or by a comparator?
  • Given this code: int x = 0, y = 4, z = 5; if (x > 2) { if (y < 5) { System.out.println("message one"); } else { System.out.println("message two"); } } else if (z > 5) { System.out.println("message three"); } else { System.out.println("message four"); } What is printed?
  • What is the main purpose of the double-checked locking pattern with volatile in lazy initialization?
  • Which class is used to write objects to a file?
  • JSON stands for JavaScript Object Notation.
  • What does System.out.println(5 + 3); print?
  • What is the value of d after calling substring(1,7) on the string 'bookkeeper' if the returned value is not assigned to any variable?
  • Consider a snippet that creates a StringBuilder sb with '12345678', sets its length to 5, then attempts to set length to 10, and then prints sb.length() with an invalid argument; will it compile?
  • In a nested loop that builds 11 rows (i from 0 to 10) each row containing 11 elements (j from 0 to 10), how many elements are in each inner row?
  • Which statement about Path and Files APIs is true?
  • Who is considered the father of the Java programming language?
  • Given the method skeleton with invalid syntax in Java, such as int radix 2; and misused else blocks, what is the result of compiling this method?
  • In a two-dimensional array example where the inner loop breaks on the value 2, what is the printed sequence?
  • Which JDBC interface is used to call stored procedures?
  • Which practice most improves Java performance by reducing boxing and unnecessary synchronization?
  • In Java, what are the results of the following comparison: a = new String('x'); b = new String('x'); System.out.println(a == b); System.out.println(a.equals(b));
  • What is the primary purpose of serialVersionUID in Java serialization?
  • Given two strings created as follows: String s1 = "abc" + "def"; String s2 = new String(s1); Which statement is true?
  • What is printed when running a program with no command-line arguments that computes k = m1(args.length); k += 3 + ++k; System.out.println(k);?
  • If a program defines s as 'hello' (String) and sb as StringBuilder('hello'), then sb.reverse() is called and s.reverse() is attempted; what happens?
  • If s1 is assigned 'abc', s2 is assigned 'def', s3 is set to s2, then s2 is changed to 'ghi'; what is printed when concatenating s1, s2, and s3?
  • Consider the following code snippet: StringBuffer s = new StringBuffer("Hello"); if ((s.length() > 5) && s.append("there").equals("Fa1se")); // do nothing System.out.println("value is " + s); What is the output?
  • Which constructor initializes y when given a string argument?
  • After execution of the code fragment where int x, a = 6, b = 7; x = a++ + b++; what are the values of x, a, and b?
  • If a subclass overrides a method and an object is referenced by its superclass type, which implementation is executed at runtime?
  • What is the result of the following primes code, considering the line 'List p = = new ArrayList();' is in the program?
  • Which statement about lambda expressions is true?
  • In the given Java snippet, the line creating an ObjectOutputStream uses ObjectOutputstream (lowercase s). What is the result?
  • Which statement about interfaces and inheritance in Java is correct?
  • Which statement accurately describes PreparedStatement in JDBC?
  • Which keyword is used to create an instance of a class?
  • Can an abstract class be declared final?
  • Which statement is true about primitive types and wrapper classes in the context of autoboxing?
  • Which approach is commonly used to propagate checked exceptions from a stream operation without altering method signatures?
  • If the code compiles and reaches the try block, what will be printed?
  • Which File method tests the existence of a file or directory?
  • Which class is used to read characters and strings in Java from the console?
  • From a Java perspective, which statement best contrasts REST and SOAP web services?
  • Which annotation is used to indicate that a method overrides a method in a superclass?
  • What is the value of j after executing the following? int i = 0; int j = i++ + ++i; System.out.println(j);
  • Which of the following is a valid way to declare a String with content 'Hello'?
  • Given i = 0 and j = 11, after a loop that decrements j and increments i in the condition, what is printed?
  • How many times will the value 2 be printed in a nested loop where the outer loop iterates over three elements and the inner loop runs with a counter from 0 to 2 for each element?
  • Assume a Java program declares int size = 10; int[] arr = new int[size]; and prints each element in sequence with no separators. Without any assignment to arr, what is printed?
  • Which line creates an Employee instance?
  • Which class is used to read characters from a text file?
  • Which statement about inheritance in Java is true?
  • Can you extend an interface in Java?
  • Which pattern is commonly used for thread-safe lazy initialization using a static inner class?
  • Which statement best describes how Java passes arguments to methods?
  • Which technique can help prevent deadlocks by using a timeout when acquiring locks?
  • To use FileReader and BufferedReader, which import is necessary?
  • Which statement is true about comparing arrays with Arrays.equals(a, b) versus using a.equals(b)?
  • If a class has a static int count initialized to 0, and its constructor increments count, what is the printed value after creating three objects and printing count?
  • Which technique is commonly used to perform a deep copy by converting an object graph to a byte stream and back?
  • What is true about static fields in Java?
  • Which statement describes try-with-resources in Java?
  • When two int variables are passed to a method that attempts to swap their values by parameter, which statement is true?
  • If you store the result of d.substring(1,7) into a new variable t while d is 'bookkeeper', what is t?
  • Which statement best describes volatile variables in Java in terms of visibility and ordering?
  • Which declaration would allow the code that uses a 2D List named table to compile when inserting at the designated declaration point?
  • Which statement makes a class serializable?
  • What does Java serialization do?
  • Which statement about the default constructor in Java is true?
  • Which statement about volatile variables is false?
  • Which statement demonstrates a concise way to create a comparator that sorts by name using Java 8 features?
  • What is the result of compiling code that declares a raw List and calls sort() without a comparator?
  • What value is printed by the program that initializes var to 20 and uses a do-while with inner loops, finally printing var?
  • Which description best captures the Java Collections Framework?
  • Which is correct format of writing JSON name/value pair?
  • Which method is used to call the constructors of the superclass from the subclass?
  • Assuming the declarations int i = 10, j = 12, k = 1; k += i++ - --j; what is the value printed for k?
  • Which statement about abstract methods is true?
  • Which declaration initializes an array in a single statement with exactly five elements?
  • Given int[] a = {1, 2, 3}; int[] b = {1, 2, 3}; System.out.println(a == b);
  • Which checked exception must be handled or declared when performing file I/O operations in Java?
  • Which statement best describes the difference between character streams and byte streams in Java?
  • Which statement about the enum-based singleton pattern is true?
  • Which operator or keyword is used to determine the type of an object at runtime in Java?
  • Which statement about CopyOnWriteArrayList is true?
  • Which statement will cause the Travel.go() method to compile? public class Travel { ArrayList<Hotel> go() { // insert code here } }
  • Which of the following keywords cannot be used when declaring a class?
  • What will happen when adding null to a List<Integer> and then summing with auto-unboxing?
  • What happens to the monitor when a thread calls wait() on an object?
  • Which statement accurately describes immutability in Java?
  • What is the difference between default methods in interfaces and abstract classes in Java?
  • Which type of dependency injection in Spring provides dependencies via the class constructor?
  • Which statement is true about eager initialization of a singleton?
  • Given a superclass MySuper with a constructor that prints values and a subclass MySub that calls super(2) and then prints, what is the output when creating a new MySub()?
  • Given the snippet: String s = "Hello"; if (s.length() > 5) { s += "There"; } System.out.println("value is " + s); What is printed?
  • Which statement best describes the compilation result of the code snippet that initializes an integer with syntax int k 2; while(--k) { System.out.println(k); } ?
  • How does ArrayList resize when its capacity is reached?
  • If an array has length n, what is the index of its last element?
  • Which declaration initializes an array in a single statement with five elements?
  • For the following program snippet, what happens when run with the command line arguments java Test closed?
  • Which statement correctly describes the differences among String, StringBuilder, and StringBuffer?
  • Given two int arrays arr1 and arr2 initialized as {1, 2, 3} and {1, 2, 3} respectively, what is the result of Arrays.equals(arr1, arr2) in Java?
  • In Java, if a method receives an int parameter and prints the parameter value after applying the pre-increment operator (++), what value is printed first?
  • Which of the following is a valid JSON representation for an object with name 'Alice' ?
  • String[] seasons = {"winter", "spring", "summer", "fall"}; What is seasons.length?
  • Which statement about Java wrapper types like Integer is true?
  • Which of the following is a valid JSON object literal with name Bob and age 30?
  • Which import statement is required to use ArrayList in Java?
  • What will happen when you compile and run the following Java code? abstract class Base { abstract void amethod(); static int i; } public class Derived extends Base { public static void main(String[] argv) { int[] ar = new int[5]; for (i = 0; i < ar.length; i++) System.out.print(ar[i]); } }
  • What will be printed by the two showMe() calls on the Data class, the first with an integer argument 10 and the second with the string argument 'Z'?
  • Which statement correctly describes method overloading?
  • Which statement about Java Streams is true?
  • In Java, which statement best describes the difference between shallow copies and deep copies?
  • What are the default values for elements of int[] and boolean[] when a new array is created in Java?
  • In the following Java code, which lines are printed? for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { if (i == j) { continue; } System.out.println("i = " + i + " j " + j); } }
  • What does List<? extends Number> mean for type safety?
  • Can null value be added to a List?
  • Which statement is the canonical Java main method signature for the program entry point?
  • Which statement best characterize a deep copy?
  • Given a = 5 and b = 9; x = a++ + b++; what are x, a, b after the expression?
  • What is the output of the following snippet: int a=1; int b=a++; int c=++a; System.out.println(a + " " + b + " " + c);
  • Which statement correctly describes typical error handling for file I/O in Java?
  • Which RESTful practice is specifically aimed at enabling efficient client-side caching?
  • What is the result of evaluating the following expression? String s = "ab"; String t = "a" + "b"; System.out.println(s == t);
  • Which of the following is not a primitive data type in Java?
  • Which constructor initializes x when given an integer argument?
  • Which statement initializes a list with two string elements "Name 1" and "Name 2"?
  • Which expression creates a String at compile time due to constant folding?
  • Which line can be added to the following class to ensure the final boolean field is properly initialized so the code compiles? public class InitTest { static int si = 10; int i; final boolean bool; // 1 }
  • Which approach is commonly used to expose different API versions in RESTful URLs?
  • What does List.subList(int fromIndex, int toIndex) return?
  • What is the default access modifier for an interface method?
  • Given a List<String> al that has two elements added, what is al.size()?
  • If a method assigns its String parameter to a new value, does the original variable in the caller reflect that change?
  • Which technique is commonly used to implement pagination in JDBC queries?
  • Consider a class that declares int[] ia = new int[1]; Object[] oA = new Object[1]; boolean bool; and prints ia[0] + ' ' + oA[0] + bool. What is the printed result?
  • In Java, how are primitive arguments passed to methods?
  • Given the following code, what is the result when compiling and running? A subclass attempts to override a method with a different primitive return type, and the code uses the subclass instance to call the method.
  • Which statement about garbage collection in Java is correct?
  • Which statement prints to the standard output in Java?
  • Which statement about static fields is true?
  • Which statement best describes the goal of the G1 garbage collector?
  • Which option is commonly used to read a string from standard input in Java?
  • In a do-while loop, which statement best describes how many times the loop body is executed?
  • What happens if you try to instantiate an abstract class?
  • Which tool is used to execute Java code?
  • Which characteristic defines a functional interface in Java?
  • What will happen when you compile and run code that prints a five-element int array where no values are assigned?
  • What is the value of a[3] for the array int[] a = {1, 2, 3, 4};
  • Which memory area in the JVM stores loaded class metadata?
  • Which of the following command sequences will compile a Java class named MyFirstClass and run it with the arguments hello and hello?
  • In Java, attempting to override a method in a subclass by changing its primitive return type results in what?
  • In a ragged two-dimensional array declared as int[][] a = new int[2][]; a[0] = new int[3]; a[1] = new int[2]; What is a[1].length?
  • What results from running the following code where b is 10 and c is 15, and b is assigned as (byte) (b ^ c)?
  • Which statement is true about serialization of transient and static fields in Java?
  • Which of the following is a valid way to declare an array in Java?
  • What do wait(), notify(), and notifyAll() do in Java concurrency?
  • Which of the following demonstrates polymorphism?
  • Which keyword is used to inherit a class?
  • Which statement best describes Dependency Injection and how a DI container works in Spring (basic)?
  • Which annotation meta-annotation controls whether an annotation is retained at runtime?
  • Which statement about reading and writing files with NIO is true?
  • What is the purpose of a database connection pool?
  • Which pairing is a typical combination in the Java Collections Framework?
  • If a String d initially holds 'bookkeeper', you call substring(1,7) but do not assign the result, then set d to 'w' + d, and then call append on d; what happens?
  • What is the result of the expression new String("Hello").equals("Hello")?
  • If a list l contains at least two elements, what does l.subList(1, 1) return?
  • Which feature was introduced in Java 9 as part of the module system?
  • Which command prints Hello! when run with the arguments open and someone?
  • Which statement correctly describes checked versus unchecked exceptions in Java?
  • What is a key advantage of Lock over synchronized blocks in Java?
  • If you reassign a parameter that holds an object reference inside a method, does the original reference in the caller change?
  • What is a primary benefit of using a thread pool in Java?
  • Which statement accurately reflects the equals/hashCode contract?
  • Which Optional expression correctly transforms a present value using a map to lower case?
  • In a Java program where i is initialized to 10 and a static variable j is initialized to 20, a method doubles its parameter and doubles j. After calling the method with i, what values are printed for i and j?
  • Given the following switch structure, what is printed when i equals 5? switch (i) { default: case 1: System.out.println(1); case 0: System.out.println(0); case 2: System.out.println(2); break; case 3: System.out.println(3); }
  • When used as a stack or queue, which statement is most accurate?
  • If a static int field is declared but not initialized, what is its default value?
  • What does File.length() return?
  • Which statement best differentiates method overloading from method overriding?
  • If the serialVersionUID of a class changes and you attempt to deserialize an older serialized form, what happens?
  • What was the earlier name of the Java programming language?
  • Which statement about ObjectOutputStream's writeObject method is true?
  • Which statement best describes encapsulation with a simple example?
  • Which feature of java.util.concurrent Locks allows configuring thread acquisition order?
  • Explain fail fast versus fail safe iterators with examples.
  • After the method returns, what value is printed for the original int variable in the caller when printing it in main?
  • Given a class A with a method baz and a subclass B that overrides baz, what is the result when you execute A a = new B(); a.baz()?
  • Which statement about protected access in Java is true?
  • Which class is used to write primitive data types to a stream in Java?
  • In Java, what is the purpose of the super keyword in a subclass constructor?
  • Which method reads a line of text from a BufferedReader?
  • What is printed by the following Java code snippet? int[] ar = new int[5]; for (int i = 0; i < ar.length; i++) System.out.print(ar[i]);
  • In Java Streams, which operation is terminal and triggers evaluation?
  • Which tool is used to compile Java code?
  • Which package contains the File class?
  • Which expression correctly provides a default value using Optional when x might be null?
  • In the example where a static integer a is initialized to 40, what is printed by the program?
  • What is the default value of each element in a newly created int[] array?
  • In a class SomeClass with methods of varying access modifiers, which set of method calls from another class in the same package are valid?
  • In the Computer class, the field k is declared as a Keyboard and initialized with new Keyboard(). This demonstrates what concept?
  • What is printed when the following method is invoked with an argument 4?
  • When overriding a method, which statement is true about its visibility?
  • Consider the code snippet: int arr[2]; System.out.println(arr[0]); System.out.println(arr[1]); What happens when compiling and running this code in Java?
  • What will the following program print? The variable c starts at 0 and a flag is true; within a loop the counter increments until certain conditions deactivate the flag. What is printed?
  • Which of the following is considered a common SQL anti-pattern in Java applications?
  • Evaluate the following do-while loop behavior: do{ if(count % 3 == 0) continue; sum += count; } while(count++ < 11); System.out.println(sum); If sum starts at 0 and count starts at 0, what is printed?
  • What is the key difference between map() and flatMap() in Java Streams?
  • JSON stands for which of the following?
  • Which statement about List, Set, and Map is correct?
  • Which memory area in the JVM stores Java objects?
  • What is the output of this code fragment? int x = 3; int y = 10; System.out.println(y % x);
  • When repeatedly calling readLine() on a BufferedReader until no more data remains, what is returned at end of stream?
  • How can Java achieve multiple inheritance?
  • Which statement about the modulo operator is true in Java?
  • Which statement best describes what happens when you compile and run the following code? class Triangle { public int base; public int height; private final double ANGLE; public void setAngle(double a) { ANGLE = a; } public static void main(String[] args) { Triangle t = new Triangle(); t.setAngle(90); } }
  • Generics basics and an example of a bounded wildcard.
  • Which statement best describes type erasure in Java generics?
  • Which singleton pattern is most resistant to reflection attacks and serialization issues?
  • Is String considered a wrapper class in Java?
  • In Java, what is the difference between the equality operator and the equals method?
  • In a loop that contains a break inside the inner loop, which loop is terminated by the break?
  • What is the behavior of a static field in a class?
  • Which statement about Runnable and Callable is correct?
  • In a scenario with nested loops, if the inner loop runs three times for each outer iteration, how many total inner iterations occur across all outer iterations?
  • What is autoboxing and unboxing in Java, and what are potential performance implications?
  • Which Java class is a widely used example of immutability?
  • Which statement about comparing arrays with the operator '==' is true?
  • After executing sb = new StringBuilder('12345678'); sb.setLength(5); sb.setLength(10); what is sb.length()?
  • Which statement about try-with-resources with multiple resources is true?
  • What will be printed when iterating a two-dimensional array {{1,2,3},{4,5}} with a nested loop that prints elements and breaks the inner loop when an element equals 2, followed by a continue for the outer loop?
  • In Java, when a subclass is instantiated, in what order are the constructors invoked?
  • Given int[] arr = new int[3]; System.out.println(arr.length); What is printed?
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy