Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

HomeCertifications1Z0-811DomainsPrimitives, Strings and Operators
1Z0-811Free — No Signup

Primitives, Strings and Operators

Practice 1Z0-811 Primitives, Strings and Operators questions with full explanations on every answer.

112questions

Start practicing

Primitives, Strings and Operators — choose a session length

10 questions~10 min20 questions~20 min30 questions~30 min50 questions~50 min

Free · No account required

1Z0-811 Domains

What is JavaJava Basics and SyntaxPrimitives, Strings and OperatorsControl Flow and LoopsArrays and MethodsObject-Oriented ProgrammingException Handling and Development Tools

Practice Primitives, Strings and Operators questions

10Q20Q30Q50Q

All 1Z0-811 Primitives, Strings and Operators questions (112)

Start session

Click any question to see the full explanation and answer options, or start a focused practice session above.

1

Given the code snippet: int x = 5; int y = 2; double result = x / y; What is the value of result?

2

A developer writes: String s = "Hello"; s.concat(" World"); System.out.println(s); What is the output?

3

Given: String str = "Java"; str = str.concat(" SE"); str.replace('a', 'A'); System.out.println(str); What is the output?

4

Which operator is used to compare two strings for value equality in Java?

5

What is the result of: System.out.println(10 + 20 + "30");

6

Given: boolean a = false; boolean b = true; boolean c = true; System.out.println(a || b && c); What is the output?

7

Which of the following is a valid Java identifier?

8

What is the output of: int i = 1; i = i++; System.out.println(i);

9

Which primitive type can store a single character?

10

Given: double d = 5.0; int i = d; What is the result?

11

What is the default value of a boolean variable in Java?

12

Which TWO of the following are valid ways to create a String?

13

Which THREE of the following are valid Java operators?

14

Which TWO of the following are primitive data types in Java?

15

Which THREE of the following expressions evaluate to true? (Assume int a=5, b=10)

16

What is the output?

17

What is the value of y?

18

What is the output?

19

A developer is working on a Java application that processes user input. The application reads a string from the console and needs to compare it with a predefined constant string "ADMIN". The developer writes the following code: if (input == "ADMIN") { grantAccess(); }. During testing, the condition sometimes fails even when the user enters ADMIN. The input string is obtained via Scanner.nextLine(). Which is the most likely cause and best fix?

20

A banking application uses a method to calculate interest: double calculateInterest(double balance) { return balance * 0.05; }. The method is called with an int argument: int accountBalance = 1000; double interest = calculateInterest(accountBalance); System.out.println(interest); The output is 50.0, but the expected output is 50.0. However, the developer notices that if the method is changed to return int, the output becomes 50.0 as well. Which statement about implicit casting is true?

21

A developer writes the following code: int a = 5; int b = 2; double result = a / b; System.out.println(result); What is the output?

22

Refer to the exhibit. What is the output?

23

Arrange the steps to handle an exception using try-catch-finally in Java in the correct order.

24

Arrange the steps to create and use a simple Java inheritance hierarchy in the correct order.

25

Match each primitive data type to its default value.

26

Match each Java tool to its function.

27

A developer writes the following code: String s1 = "Hello"; String s2 = "Hello"; System.out.println(s1 == s2); What is the output?

28

What is the result of the following code snippet? int a = 5; int b = 2; double c = (double) (a / b); System.out.println(c);

29

Given: short s = 10; s = s + 5; What is the result?

30

What is the output of System.out.println(1 + 2 + "3" + 4 + 5);?

31

Which of the following correctly uses the ternary operator to set int max to the larger of two ints x and y?

32

Given boolean a = true, b = false, c = true; What is the result of (a || b) && (b || c)?

33

Which primitive type can store a single character?

34

What is the output of the following? int x = Integer.MAX_VALUE; x++; System.out.println(x);

35

What is the value of z after executing: int x = 3; int y = 2; int z = x++ * --y;

36

Which TWO of the following are valid declarations and initializations of primitive variables?

37

Which TWO of the following operations on String objects result in a new String object?

38

Which THREE of the following statements about operators in Java are true?

39

What is the output of the program?

40

What is the output?

41

What is the output?

42

A developer writes: int a = 9; int b = 2; double result = a / b; System.out.println(result); What is the output?

43

Given: int i = 1; int j = i++ + ++i; What is the value of j?

44

A method returns a String. The team debates using == vs equals(). Which correctly describes String comparison in Java?

45

A developer needs to store a currency value with two decimal places. Which primitive type is most appropriate?

46

Given: String s1 = "Java"; String s2 = new String("Java"); What does (s1 == s2) evaluate to?

47

A method has parameters: int x, double y. It performs x += y; and returns x. What is the range behavior?

48

A developer writes: boolean b = !true && false; What is the value of b?

49

A developer wants to assign the largest possible long value to a variable. Which is correct?

50

A developer writes: char c = 'A'; int i = c + 1; System.out.println(i); What is the output?

51

Which TWO of the following are valid Java identifiers? (Choose 2)

52

Which TWO statements are true about the String class in Java? (Choose 2)

53

Which THREE of the following expressions compile without error? (Choose 3)

54

Refer to the exhibit. What is the output?

55

Refer to the exhibit. What is the output?

56

Refer to the exhibit. What is the output?

57

Given: int a = 9; int b = 2; double c = a / b; System.out.println(c); What is the output?

58

A developer wants to compare two String objects for content equality. Which code snippet will work correctly?

59

Given: String s1 = "Hello"; String s2 = "Hello"; String s3 = new String("Hello"); Which of the following is true?

60

Which of the following is NOT a primitive data type?

61

What is the output of the following code? int i = 0; i = i++ + ++i; System.out.println(i);

62

Which of the following is a valid declaration of a float variable?

63

What is the value of 10 % 3?

64

Which keyword is used to declare a constant in Java?

65

What is the result of the following code? Integer a = 100; Integer b = 100; System.out.println(a == b);

66

Refer to the exhibit. What is the output?

67

Refer to the exhibit. What is the result?

68

Refer to the exhibit. What is the output?

69

Which two of the following are primitive data types in Java? (Choose two)

70

Which two expressions evaluate to true? (Choose two)

71

Which three statements about String immutability are true? (Choose three)

72

What is the result of the following code snippet? int x = 5; int y = 2; double z = x / y; System.out.println(z);

73

Which of the following is a valid Java primitive type?

74

A developer needs to concatenate several string values in a loop. Which approach is most efficient for performance?

75

Given: int a = 10; int b = 20; boolean flag = a++ > 10 && ++b > 20; What are the values of a and b after execution?

76

What is the output of the following code? String s1 = "Hello"; String s2 = "Hello"; System.out.println(s1 == s2);

77

Given: byte b = 10; b = b + 1; What is the result?

78

Which operator is used to compare two values for equality in Java?

79

What is the value of the expression: 2 + 3 * 4 / 2 - 1?

80

Which of the following statements about the String class is true?

81

Which two of the following are primitives in Java? (Choose two.)

82

Which three of the following are valid ways to declare and initialize a variable of type int? (Choose three.)

83

Which two of the following operators are logical operators in Java? (Choose two.)

84

What is the cause of the compilation error?

85

Why does the code output false?

86

What is the output?

87

A developer is implementing a login verification method that compares a user-entered password against a stored hash. The passwords are stored as String objects. Which approach ensures correct comparison?

88

An integer counter variable is incremented in a loop that runs 3 billion times. Initially counter = 0. After the loop, the value is printed. Which code snippet correctly handles potential overflow?

89

Given the code snippet: double d = 10.5; int i = (int) d; System.out.println(i); What is the output?

90

A developer needs to build a SQL query string by concatenating many parts. Which approach is most efficient for repeated concatenation?

91

Evaluate the following expression: int x = 5; int y = (x > 5) ? 10 : 20; What is y?

92

Given: byte b = 10; b = b + 1; Which statement is true?

93

Which primitive type has a default value of 0.0f?

94

What is the result of the following code? int a = 8; int b = 3; System.out.println(a >> 1);

95

Given: int x = 3 + 4 * 2; What is x?

96

Which two of the following are valid ways to create a String object?

97

Which three of the following statements about primitive type conversion are true?

98

Which three of the following code snippets produce the output '5'?

99

You are developing a high-frequency trading application where performance is critical. You need to parse and concatenate trade messages. The messages are received as strings and must be combined into a single output string for logging. Each message is appended to the log string. Currently, you are using String concatenation with the '+' operator inside a loop that processes up to 10,000 messages per second. However, performance monitoring shows that the application experiences frequent garbage collection pauses, affecting throughput. Which approach should you take to reduce garbage collection overhead and improve performance?

100

You are part of a team maintaining a legacy order processing system. The system stores order totals as primitive double values. A recent bug report shows that for very large orders (around $1,000,000.00), the total after adding a tax of 8.25% is sometimes off by a few cents. The calculation is: total = orderTotal * (1 + taxRate). The taxRate is defined as double taxRate = 0.0825; The orderTotal is received as a double. The application needs exact monetary precision to two decimal places. Which solution best addresses the precision issue while minimizing changes to the existing code?

101

A junior developer wrote the following code to compare two strings entered by a user: if (username == "admin") { grantAccess(); } else { denyAccess(); }. The code always denies access even when the user enters 'admin'. What is the most likely cause, and how should the code be fixed?

102

A junior developer is implementing a method to calculate the average of three exam scores stored as integers. The method should return a double representing the average, rounded to one decimal place. The developer writes: double avg = (score1 + score2 + score3) / 3; However, the result is always an integer. Which of the following modifications ensures the correct result?

103

Which two of the following are valid ways to check if two String objects contain the same characters? (Assume s1 and s2 are non-null String references.)

104

Which three of the following are valid Java operators that can be used with primitive numeric types?

105

A financial trading application processes a batch of 10 million trade transactions every night. Each transaction is a String containing trade details such as ID, symbol, quantity, and price. The current implementation uses string concatenation with the += operator in a loop to build a summary report string. The application frequently runs out of memory and takes hours to complete. The server has 16 GB of RAM and runs Java 11. The code cannot be restructured significantly due to regulatory requirements, but performance improvements are allowed. Which course of action will most effectively resolve the performance and memory issues?

106

A stock trading system calculates daily profit using an int variable. During periods of high volatility, the profit can exceed Integer.MAX_VALUE (2,147,483,647). When this happens, the profit value wraps around to a negative number, leading to incorrect reporting. The lead developer wants to detect the overflow and throw an ArithmeticException rather than silently producing wrong results. The code cannot use long or BigInteger due to legacy constraints. Which approach should be taken?

107

A developer is implementing a login system where users enter a password that is then hashed using SHA-256. The system stores the hash as a String in the database. On login, the entered password is hashed and compared to the stored hash using the == operator. Occasionally, valid users are denied access, even though the hashes are identical when printed. The developer has confirmed that the hash algorithm is correctly implemented and that the stored hash is exactly the same string as the computed hash. What is the most likely cause and correct fix?

108

A scientific application performs calculations with double precision. A specific formula divides two double values: result = a / b; where a and b are calculated from sensor readings. The result is expected to be at most 10 decimal digits of precision. However, the output often shows small rounding errors, e.g., 0.1 + 0.2 = 0.30000000000000004. The application must meet strict accuracy requirements and cannot tolerate these small errors. Which strategy should be used to achieve exact decimal representation?

109

A developer is writing a bitmask validation method. The method should return true if both input integers (x and y) have exactly the same least significant bit set. The developer writes: if (x & y == 1) { return true; } However, the condition never evaluates to true even when both numbers are odd (least significant bit = 1). Debugging shows that x and y are positive integers. What is the root cause and the correct fix?

110

Which two statements are true about primitive data types in Java?

111

Refer to the exhibit. Given the code, what is the value printed to the console?

112

A social media platform processes user login requests. Each request generates a welcome message by concatenating the username with a fixed greeting using the + operator inside a loop that runs hundreds of times per second for thousands of users. The development team notices that the application suffers from high memory consumption and slow response times under load. They profile the code and discover that the method building the welcome message is a bottleneck. The team considers several options to improve performance while maintaining thread safety. Which approach should the team implement?

Practice all 112 Primitives, Strings and Operators questions

Other 1Z0-811 exam domains

What is JavaJava Basics and SyntaxControl Flow and LoopsArrays and MethodsObject-Oriented ProgrammingException Handling and Development Tools

Frequently asked questions

What does the Primitives, Strings and Operators domain cover on the 1Z0-811 exam?

The Primitives, Strings and Operators domain covers the key concepts tested in this area of the 1Z0-811 exam blueprint published by Oracle. Courseiva provides free domain-focused practice, mock exams, missed-question review, and readiness tracking across all 1Z0-811 domains — no account required.

How many Primitives, Strings and Operators questions are in the 1Z0-811 question bank?

The Courseiva 1Z0-811 question bank contains 112 questions in the Primitives, Strings and Operators domain. Click any question to see the full explanation and answer breakdown.

What is the best way to practice Primitives, Strings and Operators for 1Z0-811?

Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.

Can I practice only Primitives, Strings and Operators questions for 1Z0-811?

Yes — the session launcher on this page draws questions exclusively from the Primitives, Strings and Operators domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.

Free forever · No credit card required

Track your 1Z0-811 domain progress

Save your results, see per-domain analytics, and get readiness scores — free, for every certification.

Sign Up Free

Free forever · Every certification included

Practice Session

10 questions20 questions30 questions50 questions

Study Resources

All DomainsPractice TestMock ExamFlashcardsStudy Guide