Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF Questions Available Here at: https://www.certification-exam.com/en/dumps/infosys-limited- exam/lex_auth_012975476940365824839-dumps/quiz.html Enrolling now you will get access to 245 questions in a unique set of Infosys Limited LEX_AUTH_012975476940365824839 Question 1 What is the default value of a boolean instance variable in Java? Options: A. true B. false C. 0 D. null Answer: B Explanation: In Java, instance variables (fields) are automatically initialized to default values if not explicitly assigned. For the boolean primitive type, the default value is false. This is a fundamental Java language specification rule that applies to all instance and static fields. Local variables, however, are NOT given default values and must be explicitly initialized before use, or the compiler will report an error. This distinction is important — if you declare a boolean field in a class without initializing it, Java guarantees it will be false. Other primitive defaults include: int, long, short, byte default to 0; float and double default to 0.0; char defaults to the null character; and all reference types default to null. Understanding these defaults is critical when working with class design and avoiding unexpected behavior. For example, a boolean flag field in a class can safely be used after object creation without initialization. However, relying on defaults in complex code can reduce readability, so it is considered good practice to explicitly initialize fields to make the intent clear to other developers reading the code. Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/ Question 2 What is encapsulation in object-oriented programming? Options: A. Hiding implementation details by exposing only necessary interfaces B. Inheriting properties from a parent class C. Allowing one method to perform different behaviors D. Creating multiple objects from a single class Answer: A Explanation: Encapsulation is one of the four core OOP principles (along with inheritance, polymorphism, and abstraction). It refers to the bundling of data (fields) and the methods that operate on that data within a single unit (a class), and restricting direct access to the internal state from outside the class. In Java, encapsulation is achieved primarily through access modifiers — declaring fields as private and providing public getter and setter methods to allow controlled access. This approach offers several benefits: it protects the integrity of an object's state by enforcing validation in setter methods, it hides implementation details so the internal representation can change without affecting external code (loose coupling), and it makes code more maintainable and testable. For example, a BankAccount class might have a private double balance field with a public getBalance() method and a public deposit(double amount) method that validates the amount is positive before adding it. Without encapsulation, any code could directly set balance to a negative value, violating business rules. Encapsulation supports the principle of information hiding, which is fundamental to building robust, maintainable object-oriented systems. Question 3 What is the parent class of all exceptions and errors in Java? Options: A. Exception B. RuntimeException C. Error D. Throwable Answer: D Explanation: In Java, the class hierarchy for exceptions starts at the top with Throwable, which is the superclass of all Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/ errors and exceptions. Throwable has two main direct subclasses: Error and Exception. Error represents serious problems that a reasonable application should not try to catch — such as OutOfMemoryError, StackOverflowError, and VirtualMachineError. These are typically unrecoverable JVM-level issues. Exception is the superclass of all conditions that a program should handle. Exception itself has two categories: checked exceptions (subclasses of Exception but not RuntimeException) that must be declared in method signatures with throws or handled with try-catch, and unchecked exceptions (subclasses of RuntimeException) that do not need to be declared or caught. Understanding this hierarchy is fundamental for proper exception handling. Using Throwable as a catch type is generally considered bad practice because it catches Errors that the application should not suppress. Catching the specific exception type rather than a broad supertype is always preferable for clarity, appropriate handling, and avoiding accidentally swallowing unexpected problems. Question 4 Which Java collection maintains insertion order and allows duplicate elements? Options: A. HashSet B. ArrayList C. TreeSet D. HashMap Answer: B Explanation: ArrayList is the most commonly used List implementation in Java and maintains elements in the order they were inserted (insertion order). It also allows duplicate elements — you can add the same value multiple times. ArrayList is backed by a resizable array that grows by approximately 50% when the capacity is exceeded. It provides O(1) amortized time for add operations at the end, O(1) for get operations by index (random access), and O(n) for insertions/deletions in the middle (because elements must be shifted). HashSet does not maintain insertion order and does not allow duplicates. TreeSet maintains elements in sorted natural order (or a specified Comparator order) and does not allow duplicates. HashMap maps keys to values and does not maintain insertion order (LinkedHashMap does). When you need a list that preserves order, allows duplicates, and provides fast random access by index, ArrayList is the standard choice. For scenarios requiring frequent insertions/deletions in the middle, LinkedList may be more appropriate despite its slower random access. Question 5 What is a lambda expression in Java? Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/ Options: A. A named class that implements a functional interface B. An anonymous function that can be passed as a method argument C. A method that runs asynchronously D. A type of loop for collections Answer: B Explanation: A lambda expression in Java 8+ is an anonymous function — a block of code without a name that can be assigned to a variable, passed as a method argument, or returned from a method. Lambdas provide a concise way to implement functional interfaces (interfaces with a single abstract method). Syntax: (parameters) -> expression or (parameters) -> { statements; }. Examples: Runnable r = () -> System.out.println("Hello"); is a no-parameter lambda. Comparator c = (a, b) -> a.compareTo(b); is a two- parameter lambda. The type of parameters is usually inferred by the compiler. Lambda expressions dramatically reduced boilerplate code, especially for event handlers, sorting, and collection processing. Before lambdas, you needed anonymous inner classes: Runnable r = new Runnable() { public void run() { System.out.println("Hello"); } }; Lambdas can capture variables from their enclosing scope, but only effectively final variables (not modified after initialization). Lambda expressions are objects that implement functional interfaces, but they are more efficient than anonymous classes — the JVM can optimize them better using invokedynamic. Combined with the Streams API, lambdas revolutionized Java programming style toward a more functional paradigm. Question 6 What is the primary difference between a process and a thread? Options: A. Threads have their own memory space; processes share memory B. Threads are heavier than processes C. Threads are independent; processes share the same memory space within a program D. Threads share the process's memory space; processes have separate memory spaces Answer: D Explanation: A process is an independent program in execution with its own memory space (heap, stack, code segment, data segment) and system resources. Processes are isolated — one process cannot directly access another's memory. A thread is the smallest unit of execution within a process. Multiple threads within the same process share the process's memory space (heap and global data), but each thread has its own stack, program counter, and registers. This sharing makes thread communication faster and easier than Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/ inter-process communication, but also introduces concurrency challenges like race conditions and deadlocks. Threads are lighter than processes — creating a thread is faster and requires fewer resources than creating a process. Context switching between threads is also faster than between processes. The Java Virtual Machine is itself a process, and each Java thread runs within the JVM process. In Java, threads are created by extending Thread class or implementing Runnable interface. Multi-threading allows a Java application to perform multiple operations concurrently, crucial for responsive UIs, server-side request handling, and batch processing in telecom systems. The tradeoff is increased complexity in managing shared state safely. Question 7 Are String objects immutable in Java? Options: A. No, String can be modified using replace() B. Yes, String objects cannot be changed after creation C. Only string literals are immutable D. Only synchronized Strings are immutable Answer: B Explanation: Yes, String objects in Java are immutable — once created, their content cannot be changed. Methods like replace(), toUpperCase(), substring(), and concat() do NOT modify the original String; they return NEW String objects containing the result. This immutability is intentional and provides several benefits: Thread safety — multiple threads can share String objects without synchronization; String pooling — the JVM can safely intern string literals in the String pool because their content will never change; Security — passwords and file paths as Strings cannot be altered after being validated; Caching — String's hashCode is computed once and cached since the value never changes. When you do: String s = "hello"; s = s.toUpperCase(); the original String "hello" still exists in memory (until garbage collected); s now points to a new String object "HELLO". For mutable string operations (repeated concatenation in loops), use StringBuilder (single-threaded) or StringBuffer (thread-safe). Using String concatenation with + in a loop creates many intermediate String objects, causing garbage collection pressure. StringBuilder.append() mutates the same object, making it O(n) total vs O(n^2) for String concatenation in a loop. Question 8 What is a stream in Java I/O? Options: A. A thread for handling I/O Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/ B. A sequential flow of data read from or written to a source/destination C. A database connection pool D. A synchronized buffer for file access Answer: B Explanation: In Java I/O, a stream is an abstraction representing a sequential flow of data. Data flows into a program (input stream) from a source (file, network, keyboard) or flows out (output stream) to a destination (file, network, screen). Java I/O uses a stream-based model where streams handle one item at a time in sequence. Java has two main families: Byte streams (InputStream/OutputStream hierarchy) — handle raw 8-bit bytes, suitable for binary data like images, audio, or any binary file. Character streams (Reader/Writer hierarchy) — handle 16-bit Unicode characters, suitable for text data; automatically handle character encoding. Key classes: FileInputStream/FileOutputStream — bytes from/to files; FileReader/FileWriter — characters from/to files; BufferedInputStream/BufferedReader — add buffering to reduce system calls; InputStreamReader/OutputStreamWriter — bridge between byte and character streams with encoding conversion; DataInputStream/DataOutputStream — read/write Java primitives as bytes; ObjectInputStream/ObjectOutputStream — read/write serialized Java objects. Java NIO (java.nio) introduced in Java 1.4 added non-blocking I/O with Channels, Buffers, and Selectors — essential for high- performance servers like those used in telecom applications handling thousands of concurrent connections. Question 9 What is the Singleton design pattern? Options: A. A pattern for creating multiple similar objects efficiently B. A pattern ensuring a class has exactly one instance with a global access point C. A pattern where one class delegates all work to a single helper class D. A pattern for single-method classes Answer: B Explanation: The Singleton pattern ensures a class has exactly one instance throughout the application's lifetime and provides a global point of access to it. Common implementation: private constructor prevents external instantiation; private static field holds the single instance; public static getInstance() method returns the instance (creating it if necessary). Thread-safe implementations: Synchronized getInstance(): public static synchronized Singleton getInstance() — thread-safe but slow; Double-checked locking with volatile: private volatile static Singleton instance; ... if (instance == null) { synchronized(Singleton.class) { if (instance == null) { instance = new Singleton(); } } } — thread-safe and efficient; Enum Singleton (preferred): public enum Singleton { INSTANCE; } — thread-safe, serialization-safe, reflection-safe, concise. Static inner class Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/ (Bill Pugh): holder class initialized lazily when getInstance() is called — thread-safe through class loading guarantees. Use cases: logger, configuration manager, connection pool, thread pool, cache manager. Singletons are controversial in testing because they carry global state across tests. Dependency injection frameworks (Spring) manage singleton beans automatically, making explicit Singleton pattern less necessary in modern Java. In telecom, Singletons might manage shared resources like SS7 stack connections or protocol handlers. Question 10 What does DML stand for in SQL? Options: A. Data Management Language B. Data Markup Language C. Data Manipulation Language D. Database Modification Language Answer: C Explanation: DML stands for Data Manipulation Language — the subset of SQL used to insert, update, delete, and retrieve data in database tables. The four core DML statements are: SELECT (retrieves data), INSERT (adds new rows), UPDATE (modifies existing rows), and DELETE (removes rows). DML statements operate on the data within tables without changing the table structure. Contrast with DDL (Data Definition Language) which includes CREATE, ALTER, DROP, TRUNCATE — statements that define or modify database structure (schemas, tables, indexes, views). DCL (Data Control Language) includes GRANT and REVOKE for managing permissions. TCL (Transaction Control Language) includes COMMIT, ROLLBACK, and SAVEPOINT for managing transactions. DML operations are typically enclosed in transactions and can be rolled back if needed (unlike DDL in most databases which implicitly commits). In Oracle and PostgreSQL, DDL is auto-committed; in SQL Server, DDL can be rolled back. Understanding the SQL sublanguage categories is fundamental for database developers and is tested in SQL certifications. In telecom databases, DML is used constantly to query call records, update subscriber data, insert billing events, and delete expired session data. Would you like to see more? Don't miss our Infosys Limited LEX_AUTH_012975476940365824839 PDF file at: h t t p s : / / w w w . c e r t i f i c a t i o n - e x a m . c o m / e n / p d f / i n f o s y s - l i m i t e d - pdf/lex_auth_012975476940365824839-pdf/ Infosys Limited Infosys Limited LEX_AUTH_012975476940365824839 PDF https://www.certification-exam.com/