All fields

“Java Fundamentals: Syntax” in Information Technology

50 questions across 1 technology.

Information Technology

50 questions in 1 technology

#QuestionTechnologyTopicLevel
1What is the difference between a Java text block (introduced as a standard feature in Java 15) and a traditional String literal, and what specific syntax rules govern indentation handling? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
2How does Java's compound assignment operator (like +=) implicitly include a narrowing cast that a corresponding explicit expanded assignment (x = x + y) does not, and what surprising behavior results from this? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced
3What are the eight primitive data types in Java, and how do they differ fundamentally from reference types like String or a custom class? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsBeginner
4How does Java's operator precedence and associativity determine the evaluation order of a complex expression, and what are some common precedence-related mistakes? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
5How does Java's short-circuit evaluation for && and || operators differ from the non-short-circuiting & and | operators when applied to boolean operands, and why does this distinction matter for avoiding NullPointerException? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
6How does Java's autoboxing and unboxing mechanism work at the bytecode level, and what specific performance and correctness pitfalls does it introduce in seemingly innocuous code, such as within a loop? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced
7How does Java's implicit numeric type promotion and narrowing/widening conversion rules work, and what specific data-loss or precision risks does an implicit narrowing conversion (requiring an explicit cast) guard against? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced
8How does the var keyword (local variable type inference, introduced in Java 10) work, and what specific restrictions apply to where it can and cannot be used, given Java remains a statically-typed language? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced
9How does Java's integer division and modulo operator behave with negative operands, and how does this differ from the mathematical definition of modulo used in some other contexts (like array indexing wraparound)? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced
10How does Java's String immutability, combined with the string pool, interact with security-sensitive code (like handling passwords), and why is char[] generally recommended over String for storing sensitive data temporarily in memory? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced
11What is the difference between the == operator and the .equals() method when comparing two custom objects, if the class hasn't overridden equals()? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsBeginner
12What is the difference between the == operator and the .equals() method when comparing String objects, and why does String's string pool (interning) behavior sometimes make == appear to 'work' for strings? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
13What is the difference between the ++ (increment) and -- (decrement) operators used in prefix versus postfix position, and what subtle bug can arise from using them within a complex expression? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
14What is the difference between a compile-time constant expression and a regular final variable, and why does this distinction matter for switch statement case labels and certain compiler optimizations? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
15What is the difference between an instance initializer block and a static initializer block, and when does each execute relative to a class's constructors? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
16How would you determine whether a given year is a leap year, and calculate the number of days in a specific month, using the java.time API's built-in support rather than hand-writing this classic calendrical logic? Java › Java Date & Time API (java.time)JavaJava Date & Time API (java.time)Intermediate
17How would you write and run a basic 'Hello World' JPMS-modularized application from scratch, including the module-info.java, directory structure, and the specific javac/java command-line invocations needed? Java › Java Platform Module System (JPMS)JavaJava Platform Module System (JPMS)Intermediate
18What is the multi-catch syntax (catch (IOException | SQLException e)) introduced in Java 7, and what restriction applies to the exception types combined in a single multi-catch block? Java › ExceptionsJavaExceptionsIntermediate
19How would you calculate the difference between two dates or times using Period and Duration, and what's the distinction between these two classes? Java › Java Date & Time API (java.time)JavaJava Date & Time API (java.time)Intermediate
20How do you parse and format date/time values using DateTimeFormatter, and how does this replace the older, notoriously thread-unsafe SimpleDateFormat class? Java › Java Date & Time API (java.time)JavaJava Date & Time API (java.time)Intermediate
21What are annotations in Java, and what purpose do they serve? Java › AnnotationsJavaAnnotationsBeginner
22How do you declare, initialize, and access elements of a one-dimensional array in Java? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysBeginner
23What problem do build tools like Maven and Gradle solve for a Java project? Java › Build Tools: Maven & GradleJavaBuild Tools: Maven & GradleBeginner
24What is an enum in Java, and how does it differ from simply using a set of integer or String constants? Java › EnumsJavaEnumsBeginner
25What is the difference between checked and unchecked exceptions in Java, and how does the compiler treat each differently? Java › ExceptionsJavaExceptionsBeginner
26What is the basic syntax and control flow of a try-catch-finally block, and what determines which catch block (if multiple exist) handles a thrown exception? Java › ExceptionsJavaExceptionsBeginner
27What is the difference between byte streams (InputStream/OutputStream) and character streams (Reader/Writer) in the classic java.io package? Java › I/O & NIOJavaI/O & NIOBeginner
28How do you instantiate a non-static inner class from OUTSIDE the enclosing class (from a different class entirely), and what is the exact syntax required? Java › Inner Classes & Anonymous ClassesJavaInner Classes & Anonymous ClassesBeginner
29What is the difference between the @Nullable/@NonNull annotations (from libraries like JetBrains or JSR-305) and Java's built-in Optional type for expressing nullability? Java › AnnotationsJavaAnnotationsIntermediate
30How do multidimensional arrays work in Java, and how do they differ from truly rectangular arrays in languages like C? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysIntermediate
31How do you configure the Maven Compiler Plugin to target a specific Java language version, and what's the difference between source, target, and release configuration? Java › Build Tools: Maven & GradleJavaBuild Tools: Maven & GradleIntermediate
32What are the immutable collection factory methods (List.of(), Set.of(), Map.of()) introduced in Java 9, and how do they differ from Collections.unmodifiableList()? Java › Collections FrameworkJavaCollections FrameworkIntermediate
33How do you correctly use an enum as a switch statement/expression's target, and what changed with the introduction of arrow-style switch expressions (Java 14+) regarding exhaustiveness and fall-through? Java › EnumsJavaEnumsIntermediate
34How does Objects.equals() and Objects.hash() from java.util.Objects simplify writing correct equals() and hashCode() implementations, particularly regarding null-safety? Java › equals(), hashCode() & toString() ContractsJavaequals(), hashCode() & toString() ContractsIntermediate
35How would you access the enclosing outer class's instance from within a nested inner class when there's a naming conflict (like a shadowed field with the same name), using the OuterClassName.this syntax? Java › Inner Classes & Anonymous ClassesJavaInner Classes & Anonymous ClassesIntermediate
36How do type annotations (introduced in Java 8, JSR 308) differ from traditional declaration annotations, and what new locations can they target? Java › AnnotationsJavaAnnotationsAdvanced
37How does Java's type inference determine the target type for a lambda expression in an ambiguous overload scenario, and what happens when a lambda could match multiple overloaded methods accepting different functional interfaces? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
38How do you declare and initialize an array of objects (reference types) versus an array of primitives, and what is the key difference in their default values? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysBeginner
39What is the standard Maven directory layout, and why does following this convention matter? Java › Build Tools: Maven & GradleJavaBuild Tools: Maven & GradleBeginner
40How do you read all bytes or all lines of a small-to-medium text file in a single, concise call using modern NIO.2 utility methods? Java › I/O & NIOJavaI/O & NIOBeginner
41Can an interface declare instance fields, and if so, what implicit modifiers are automatically applied to any field declared in an interface? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesBeginner
42How do annotations with elements (parameters) work, including default values and the special `value` element? Java › AnnotationsJavaAnnotationsIntermediate
43How do you correctly iterate a 2D array using both traditional indexed for-loops and the enhanced for-each loop, and when is each approach preferable? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysIntermediate
44How does Gradle's build script (build.gradle / build.gradle.kts) differ structurally from Maven's declarative XML pom.xml? Java › Build Tools: Maven & GradleJavaBuild Tools: Maven & GradleIntermediate
45How would you use an enum to represent a fixed set of configuration keys combined with a shared lookup method, avoiding scattered String literal keys throughout a codebase? Java › EnumsJavaEnumsIntermediate
46What is the relationship between equals() and the == operator when comparing primitive types versus reference types, and how does this affect comparing boxed wrapper types like Integer? Java › equals(), hashCode() & toString() ContractsJavaequals(), hashCode() & toString() ContractsIntermediate
47How does a local or anonymous class defined inside a static method or static context differ from one defined inside an instance method, regarding what enclosing state it can access? Java › Inner Classes & Anonymous ClassesJavaInner Classes & Anonymous ClassesIntermediate
48How would you implement a custom enum that also functions as a lookup table (mapping an external code to a constant), such as parsing an HTTP status code string into an enum constant, handling unknown values gracefully? Java › EnumsJavaEnumsAdvanced
49How does a lambda expression capture variables from its enclosing scope, and why must captured local variables be effectively final? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
50How would you correctly handle character encoding when reading a text file whose encoding isn't known in advance (or might not be UTF-8), and what pitfalls exist with relying on the JVM's platform default charset? Java › I/O & NIOJavaI/O & NIOAdvanced