Java Certified Foundations Associate (1Z0-811) Free Practice Tests
The answers to the questions below are waiting for you at the end of this blog. Keep reading to discover them!
1. Which of the following is true about Java bytecode?
- A. It can only be executed on the machine where it was compiled.
- B. It can be executed on any platform that has a compatible Java Virtual Machine (JVM).
- C. It can be executed on any operating system but only on specific hardware architectures.
- D. It needs to be compiled separately for each operating system and hardware architecture to run properly.
2. Given the following code:
Which two lines can be inserted at locations marked //1
and //2
?
- A.
import java.util.*;
at//1
- B.
import java.lang.*;
at//1
- C.
package example;
at//1
- D.
package com.example;
at//2
- E.
import java.lang.*;
at//2
- F.
import java.util.*;
at//2
3. Which of the following can be valid declarations of a string variable?
- A.
string message = "Hello";
- B.
public String message = "Hello";
- C.
final String message = "Hello";
- D.
String message = "Hello";
- E.
static string message = "Hello";
4. What will be printed when the following code snippet is executed?
- A.
d
- B.
e
- C.
f
- D. This will not compile
5. Given:
What is the result?
- A.
30
- B.
33
- C.
40
- D.
66
- E. Compilation failure
- F. Exception at run time
6. Which of the following four constructs are valid?
- A. 1, 3
- B. 1, 2, 3
- C. All are valid.
- D. 3, 4
- E. 1, 2, 4
7. What will be the result of attempting to compile and run the following program? Given:
What can be inserted in the above code so that it will print 123 Laptop
?
- A.
Product product = new Product(); product.productId = 123; product.productName = "Laptop";
- B.
Product product = new Product(123, "Laptop");
- C.
Product product = new Product(); product.setProductId(123); product.setProductName("Laptop");
- D.
Product product = null; product.productId = 123; product.productName = "Laptop";
- E.
Product product; product.productId = 123; product.productName = "Laptop";
8. Given the following code:
What will be the result?
- A. The code will compile without error and will terminate without problems when run.
- B. The code will fail to compile, since the 'continue' can't be used this way.
- C. The code will fail to compile, since the 'break' can't be used this way.
- D. The code will fail to compile, since the do-while loop in line 3 is invalid.
- E. The code will compile without error but will never terminate.
9. Which of the following statements are true?
- A. A non-static method can directly access static variables and methods in the same class.
- B. A static method can call non-static methods directly in the same class using the 'this' keyword.
- C. Every object of a class shares a single copy of static variables.
- D. Instance methods can access local variables of static methods.
- E. Static methods are implicitly passed a 'this' parameter when called.
10. Identify valid for
constructs:
- A.
for(int i = 0; i < 10; i++) { System.out.println("valid"); }
- B.
for(int i = 0; ; i++) { if(i == 5) break; }
- C.
for(; i < 5; i++) { System.out.println(i); }
- D.
for(int i = 0; i < 5; ) { System.out.println(i); i++; }
11. A try statement must always have a ............. associated with it.
- A.
catch
- B.
throws
- C.
finally
- D.
catch, finally or both
- E.
throw
12. Which of the following statements about lists are correct?
- A. A list can dynamically grow or shrink in size.
- B. Lists can only store elements of primitive types.
- C. Every list has a built-in property named 'length' which tells you the number of elements in the list.
- D. Every list has an implicit method named 'size' which tells you the number of elements in the list.
- E. Element indexing for lists as well as for arrays starts at 1.
Looking to ace your Java exam? 🚀
Boost your preparation for the Java Certified Foundations Associate (1Z0-811) exam with tons of practice questions and answers! 📚
✅ Test your knowledge with multiple-choice questions ✅ Dive deeper into core Java concepts ✅ Improve your chances of passing with expert-level questions!
✨ Click Here to Level Up Your Java Skills! 🚀 ✨ unlock a whole new level of practice and strengthen your skills! 💡