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.

Java FPT Software Academy Practice Test 2026 – Your All-in-One Guide to Exam Success! course image
All questions

These questions are part of the practice quiz. Start practicing

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

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy