Programming Language MCQ IT Officer(PSC)
MCQs from PAGE1
1. ______ is a condition in which the memory is dynamically reserved but isn't accessible to any program.
a) Pointer Leak
b) Frozen Memory
c) Dangling Pointer
d) Memory Leak
Correct Answer: d
Explanation: A memory leak occurs when dynamically allocated memory is not freed and becomes inaccessible to the program, leading to resource wastage. A dangling pointer refers to a pointer that points to deallocated memory, and a pointer leak is not a standard term. The correct answer is "d".
2. Which of these is NOT a relational or logical operator?
a. =
b. ||
c. =
d. !=
Correct Answer: c
Explanation: The options include relational operators (=, !=) and logical operators (|| for OR). However, = is likely a typo and intended as == (equality operator). Assuming the question intends to identify an invalid operator, = (assignment) is not a relational or logical operator, unlike == (comparison). The answer sheet lists "a," but given the context, "c" (if corrected to =) is the intended non-operator. However, based on standard interpretation, "a" (if meant as = vs. ==) is accepted per the sheet. The correct answer is "a" (with clarification needed).
3. Out of the following, which one is not valid as an if-else statement?
a. if ((char) x) { }
b. if (x) { }
c. if (func1(x)) { }
d. if (if (x==1)) { }
Correct Answer: d
Explanation: In C, an if statement requires a condition that evaluates to a boolean or integer value. Options a, b, and c are valid (casting x to char, using x directly, or a function call). Option d is invalid because if cannot contain another if as its condition—nested if statements must be within braces or separate statements. The correct answer is "d".
4. We cannot use the keyword 'break' simply within
a. while
b. for
c. if-else
d. do-while
Correct Answer: c
Explanation: The break keyword is used to exit loops (e.g., while, for, do-while) or switch statements, but it cannot be used standalone within an if-else block unless it is inside a loop or switch. The correct answer is "c".
5. The global variables are
a. External
b. Internal
c. Both External and Internal
d. None of the above
Correct Answer: a
Explanation: Global variables are defined outside all functions and are accessible throughout the program, making them external in scope. They are not internal (local to a function). The correct answer is "a".
6. Out of the following operations, which one is not possible in the case of a register variable?
a. Global declaration of the register variable
b. Copying the value from the memory variable
c. Reading any value into the register variable
d. All of the above
Correct Answer: d
Explanation: Register variables are stored in CPU registers for fast access, but they cannot be globally declared (limited to local scope), and their values cannot be directly copied from memory variables or read into (due to register constraints). All options are invalid, so the correct answer is "d".
7. The #include <stdio.h> is a
a. Inclusion directive
b. File inclusion directive
c. Preprocessor directive
d. None of the above
Correct Answer: c
Explanation: #include <stdio.h> is a preprocessor directive that instructs the compiler to include the stdio.h header file before compilation. The correct answer is "c".
8. Which of these properties of #define is false?
a. These always obey the scope rules
b. We can make use of a pointer to #define
c. The #define can be externally available
d. All of the above
Correct Answer: d
Explanation:
- a) False: #define macros do not obey scope rules; they are global after definition.
- b) False: Pointers cannot be used with #define as it performs text substitution, not variable handling.
- c) False: #define is not externally available in the traditional sense; it is a compile-time construct.
All statements are false, so the correct answer is "d".
9. The correct format of declaring a function is:
a. type_of_return name_of_function (argument type);
b. type_of_return name_of_function (argument type) { }
c. type of return (argument type) name of function;
d. all of the above
Correct Answer: a
Explanation: The correct function declaration syntax in C is return_type function_name(parameter_type);, e.g., int add(int a);. Option b includes a body (definition), and c is syntactically incorrect. The correct answer is "a".
*10. Comment on the C statement given below: int (p)[5];
a. A ragged array
b. An array "p" of pointers
c. A pointer "p" to an array
d. None of the above
Correct Answer: c
Explanation: int (*p)[5] declares p as a pointer to an array of 5 integers. It is not an array of pointers or a ragged array (jagged arrays are not standard in C). The correct answer is "c".
11. We can test the presence of a loop in a linked list by
a. Comparing the node's address with the address of all the other nodes
b. Travelling the list. In case we encounter the NULL, then no loop exists
c. Comparing the stored values of a node with the values present in all the other nodes
d. None of the above
Correct Answer: a
Explanation: To detect a loop, compare each node's address with all previous nodes (e.g., using Floyd's cycle-finding algorithm or a visited set). Option b fails if a loop exists (no NULL), and c compares values, not addresses. The correct answer is "a".
*12. Determine what's true for x, if we define x as "int x[10];"?
a. This definition will only allocate 10 pointers but will not initialize them
b. The initialization must be explicitly performed
c. The definition will only allocate 10 pointers but will not initialize them. Also, the initialization has to be explicitly performed.
d. Error
Correct Answer: c
Explanation: int *x[10] declares x as an array of 10 pointers to integers. It allocates space for 10 pointers but does not initialize them; explicit initialization is required. The correct answer is "c".
*13. Which of these is the correct initialization method for the following: typedef char string;
a. More than a single space shouldn't be given when we are using typedef
b. *string p = 'A';
c. string p = "Hello";
d. *string *p = "Hello";
Correct Answer: c
Explanation: With typedef char *string, string is a pointer to a character array. string p = "Hello"; correctly initializes p as a pointer to the string literal. Option b assigns a single char, and d is invalid syntax. The correct answer is "c".
14. We can determine the size of a union with the help of the size of
a. The sum of all the members' sizes
b. The biggest member of the union
c. The last member of the union
d. The first member of the union
Correct Answer: b
Explanation: In a union, all members share the same memory space, and the size is determined by the largest member to accommodate the largest data type. The correct answer is "b".
15. Out of the following snippet, which one will generate random numbers effectively?
a. rand(time(NULL));
b. rand(10);
c. rand();
d. all of the above
Correct Answer: c
Explanation: rand() generates pseudo-random numbers, but for effectiveness, it should be seeded with srand(time(NULL)) first (not shown here). Without seeding, rand() alone works, while a and b misuse it (passing arguments). The correct answer is "c" per the intent of generating numbers.
16. We can achieve the modulus for float by:
a. x % y
b. modulus(x, y);
c. fmod(x, y);
d. mod(x, y);
Correct Answer: c
Explanation: In C, the % operator works only with integers. For floating-point modulus, fmod(x, y) from <math.h> is used. The correct answer is "c" (note: answer sheet lists "d," likely a typo; "c" is correct).
17. ______ tells a compiler that the data would be defined somewhere and it would be connected to the linker.
a) variable
b) yvals
c) errno
d) extern
Correct Answer: d
Explanation: The extern keyword informs the compiler that a variable or function is defined elsewhere and will be linked later. The correct answer is "d".
18. The definition of the function abort() is in which header file?
a) stdlib.h
b) assert.h
c) stdio.h
d) stdarg.h
Correct Answer: a
Explanation: The abort() function, which terminates the program abnormally, is defined in <stdlib.h>. The correct answer is "a".
MCQs from PAGE2
19. What is the primary purpose of the preprocessor directive #error?
a) Rectifies the first error occurring in the code
b) Rectifies the errors present in a code
c) Causes a preprocessor to ignore any error
d) Causes a preprocessor to report some fatal error
Correct Answer: d
Explanation: The #error directive forces the preprocessor to issue a fatal error message and stop compilation, typically used for debugging or enforcing conditions. The correct answer is "d".
MCQs from PAGE2 (Continued)
1. Which of these types is not provided by C but is provided by C++?
a. double
b. float
c. bool
d. int
Correct Answer: c
Explanation: C does not have a native bool type (uses int with 0/1), while C++ introduces bool as a distinct type. The correct answer is "c".
2. Which concept do we use for the implementation of late binding?
a. Static Functions
b. Constant Functions
c. Operator Functions
d. Virtual Functions
Correct Answer: d
Explanation: Late binding (dynamic polymorphism) is implemented using virtual functions in C++, allowing the function to be resolved at runtime. The correct answer is "d".
3. Which of these won't return any value?
a. void
b. null
c. free
d. empty
Correct Answer: a
Explanation: The void keyword indicates a function that does not return a value. null is not a keyword, and free/empty are not return types. The correct answer is "a".
4. Which function do we use for checking if a character is a space or a tab?
a. isdigit()
b. isblank()
c. isalnum()
d. isalpha()
Correct Answer: b
Explanation: isblank() from <ctype.h> checks if a character is a space or tab. The correct answer is "b".
5. What would happen in case one uses a void in the passing of an argument?
a. It would return any value
b. It may not or may depend on a declared return type of any function. The return type of the function is different from the passed arguments
c. It would return some value to the caller
d. It would not return any value to the caller
Correct Answer: d
Explanation: Using void as an argument (e.g., void func(void)) indicates no parameters, and the function does not return a value to the caller. The correct answer is "d".
6. ______ is an ability of grouping certain lines of code that we need to include in our program?
a. macros
b. modularization
c. program control
d. specific task
Correct Answer: b
Explanation: Modularization involves grouping code into modules or functions for reusability and maintainability. The correct answer is "b".
7. Which of these keywords do we use for the declaration of the friend function?
a. myfriend
b. classfriend
c. friend
d. firend
Correct Answer: c
Explanation: The friend keyword in C++ is used to declare a friend function that can access private members of a class. The correct answer is "c".
8. What is used for dereferencing?
a. pointer with asterix
b. pointer without asterix
c. value with asterix
d. value without asterix
Correct Answer: a
Explanation: Dereferencing a pointer in C/C++ uses the * operator (asterisk) to access the value at the pointer's address. The correct answer is "a".
9. What does polymorphism stand for?
a. a class that has four forms
b. a class that has two forms
c. a class that has only a single form
d. a class that has many forms
Correct Answer: d
Explanation: Polymorphism in OOP allows a class to take many forms (e.g., through function overriding or overloading). The correct answer is "d".
10. What handler do we use if we want to handle all the types of exceptions?
a. try-catch handler
b. catch-none handler
c. catch-all handler
d. catch handler
Correct Answer: c
Explanation: A catch-all handler (e.g., catch(...) in C++) handles all types of exceptions. The correct answer is "c".
11. What do we use in order to throw an exception?
a. try
b. throw
c. handler
d. catch
Correct Answer: b
Explanation: The throw keyword is used to explicitly throw an exception in C++. The correct answer is "b".
12. We can apply RTTI to which of the class types?
a. Polymorphic
b. Encapsulation
c. Static
d. Derived
Correct Answer: a
Explanation: Run-Time Type Information (RTTI) is applicable to polymorphic classes (those with virtual functions) in C++ for dynamic casting. The correct answer is "a".
13. Which header file do we use for the generation of random numbers?
a. <random>
b. <generator>
c. <distribution>
d. <gen_dist>
Correct Answer: a
Explanation: The <random> header in C++ provides facilities for random number generation. The correct answer is "a".
14. Which container is the best for keeping a collection of various distinct elements?
a. queue
b. set
c. heap
d. multimap
Correct Answer: b
Explanation: A set in the STL automatically maintains unique elements, making it ideal for distinct collections. The correct answer is "b".
15. Inheritance models which type of relationship?
a. Belongs-to relationship
b. Part-Of relationship
c. Is-A relationship
d. Has-A relationship
Correct Answer: c
Explanation: Inheritance models an "Is-A" relationship (e.g., a Dog is a Mammal). The correct answer is "c".
16. In heap, which of these values will be pointed out first?
a. First value
b. Lowest value
c. Third value
d. Highest value
Correct Answer: d
Explanation: In a max-heap, the highest value is at the root (pointed to first). In a min-heap, it’s the lowest, but max-heap is the default context. The correct answer is "d".
17. Which of these functions is used for incrementing the iterator by a certain value?
a. move()
b. prev()
c. advance()
d. next()
Correct Answer: c
Explanation: The advance() function in C++ moves an iterator by a specified number of positions. The correct answer is "c".
18. In the locale object, which of these objects' information is loaded?
a. secant object
b. facet object
c. instead object
d. both b and c
Correct Answer: b
Explanation: A locale object in C++ loads facet objects, which handle specific cultural formatting (e.g., date, currency). The correct answer is "b".
19. Which of these mathematics libraries is used in C++ for vector manipulation?
a. blitz++
b. stac++
c. vec+
d. cli++
Correct Answer: a
Explanation: blitz++ is a C++ library for high-performance vector and array manipulation. The correct answer is "a".
20. Which of these operators is used in order to capture every external variable by reference?
a.
b. &&
c. &
d. =
Correct Answer: c
Explanation: In C++11 lambda expressions, the & operator captures all external variables by reference. The correct answer is "c".
MCQs from PAGE3
1. Which of these components are used in a Java program for compilation, debugging, and execution?
a. JDK
b. JVM
c. JRE
d. JIT
Correct Answer: a
Explanation: The Java Development Kit (JDK) includes tools for compilation (javac), debugging, and execution, encompassing JVM and JRE. The correct answer is "a".
2. Which of these literals can be contained in a float data type variable?
a. -3.4e+050
b. +1.7e+308
c. -3.4e+038
d. -1.7e+308
Correct Answer: c
Explanation: A float in Java has a range up to approximately ±3.4e+038. Option c fits within this range, while a and d exceed it (double range), and b is a double literal. The correct answer is "c".
3. What is BigDecimal.ONE?
a. it is a custom-defined statement
b. it is a wrong statement
c. it is a static variable that has a value of 1 on a scale of 0
d. it is a static variable that has a value of 1 on a scale of 10
Correct Answer: c
Explanation: BigDecimal.ONE is a static constant in Java’s BigDecimal class, representing 1 with a scale of 0 (no decimal places). The correct answer is "c".
4. When an expression consists of int, double, long, float, then the entire expression will get promoted into a data type that is:
a. float
b. double
c. int
d. long
Correct Answer: b
Explanation: In Java, the expression is promoted to the widest type present, which is double (wider than float, long, or int). The correct answer is "b".
5. Out of these statements, which ones are incorrect?
a. The Brackets () have the highest precedence
b. The equal to = operator has the lowest precedence
c. The addition operator + and the subtraction operator - have an equal precedence
d. The division operator / has comparatively higher precedence as compared to a multiplication operator
Correct Answer: d
Explanation:
- a) True: Parentheses have the highest precedence.
- b) True: Assignment (=) has low precedence.
- c) True: + and - have equal precedence.
- d) False: / and * have equal precedence, not / higher than *.
The correct answer is "d".
6. What is it called when the child object also gets killed when the parent object is killed in the program?
a. Encapsulation
b. Association
c. Aggregation
d. Composition
Correct Answer: d
Explanation: Composition is a strong relationship where the child object’s lifecycle is tied to the parent (if the parent is destroyed, the child is too). The correct answer is "d".
7. How does one identify if a compilation unit is an interface or class from a class file?
a. Extension of the compilation unit
b. Java source file header
c. The class and interface cannot be differentiated
d. The unit type must be used to postfix interface or class name
Correct Answer: b
Explanation: The Java source file header (e.g., class or interface keyword) indicates the type, visible in the source (.java) file before compilation. The correct answer is "b".
8. Out of these methods of the String class, which one can be used for testing the strings for equality?
a. isequals()
b. isequal()
c. equals()
d. equal()
Correct Answer: c
Explanation: The equals() method in the String class tests for content equality. The correct answer is "c".
9. What would happen to the thread whenever the garbage collection kicks off?
a. The garbage collection won't happen until the running of the thread
b. The thread would continue its operation
c. The garbage collection and the thread don't interfere with each other
d. The thread would be paused while the running of the garbage collection
Correct Answer: d
Explanation: In Java, the garbage collector may pause threads to reclaim memory, though modern JVMs use concurrent collection to minimize this. The correct answer is "d".
10. Out of these, which one is the correct way of calling a constructor that has no parameters of the superclass A by the subclass B?
a. superclass.();
b. super(void);
c. super();
d. super.A();
Correct Answer: c
Explanation: In Java, super(); calls the no-argument constructor of the superclass. The correct answer is "c".
11. Out of these methods of the Object class, which one can clone an object?
a. Object clone()
b. clone()
c. Object copy()
d. copy()
Correct Answer: a
Explanation: The clone() method in the Object class (when overridden) creates a copy of an object, requiring the Cloneable interface. The correct answer is "a".
12. Out of these packages, which one contains an abstract keyword?
a. java.util
b. java.lang
c. java.system
d. java.io
Correct Answer: b
Explanation: The abstract keyword is part of the java.lang package, which is implicitly imported. The correct answer is "b".
13. Out of these methods, which one can be used for converting all the characters present in a String into an Array of characters?
a. both getChars() & toCharArray()
b. both charAt() & getChars()
c. charAt()
d. all of the mentioned
Correct Answer: a
Explanation: toCharArray() converts a String to a char[], and getChars() copies characters into an existing array. The correct answer is "a".
14. What value is returned by the compareTo() function in case the invoking string happens to be greater than the compared string?
a. a value that is greater than zero
b. a value that is less than zero
c. zero
d. none of the above
Correct Answer: a
Explanation: compareTo() returns a positive value if the invoking string is greater than the compared string (based on lexicographical order). The correct answer is "a".
15. Out of these exceptions, which one is thrown by the compareTo() method that is defined in a double wrapper?
a. SystemException
b. ClassCastException
c. IOException
d. CastException
Correct Answer: b
Explanation: The compareTo() method in Double throws ClassCastException if the argument is not a Double or its wrapper. The correct answer is "b".
16. Where does the String Pool get stored?
a. Metaspace
b. Java Stack
c. Java Heap
d. Permanent Generation
Correct Answer: c
Explanation: In modern Java (post-JDK 8), the String Pool is stored in the Java Heap (specifically the heap’s string table). The correct answer is "c".
17. Out of these data members of the HttpResponse class, which one is used for the storage of the response that is from an http server?
a. address
b. status
c. statusCode
d. statusResponse
Correct Answer: c
Explanation: The statusCode field in HttpResponse (e.g., in Java’s HTTP libraries) stores the HTTP response status code (e.g., 200). The correct answer is "c".
18. Out of these methods, which one makes the raw MIME formatted string?
a. toString()
b. getString()
c. parse()
d. parseString()
Correct Answer: a
Explanation: The toString() method can be overridden to provide a raw MIME-formatted string representation in some contexts (e.g., HTTP responses). The correct answer is "a".
MCQs from PAGE4
19. The remover() method throws which of these exceptions:
a. ObjectNotFoundException
b. IllegalStateException
c. IOException
d. SystemException
Correct Answer: b
Explanation: The remove() method (e.g., in Iterator or Collection) throws IllegalStateException if called improperly (e.g., before next()). The correct answer is "b".
20. Out of the following, which one is a superclass of all the exception type classes?
a. String
b. Runtime Exceptions
c. Catchable
d. Throwable
Correct Answer: d
Explanation: The Throwable class is the superclass of all exceptions and errors in Java. The correct answer is "d".
21. What happens when we call two threads that have the same priority to process simultaneously?
a. Both of the threads will be simultaneously executed
b. Any one of the threads can be executed first lexicographically
c. It depends on the OS
d. There will be no execution of threads
Correct Answer: c
Explanation: Thread scheduling with equal priority depends on the operating system’s scheduler (e.g., time-sharing or preemption). The correct answer is "c".
22. Out of these classes, which one is used for reading strings and characters in Java from the console?
a. StringReader
b. BufferedReader
c. InputStreamReader
d. BufferedStreamReader
Correct Answer: b
Explanation: BufferedReader (often wrapped around InputStreamReader) is commonly used to read strings and characters from the console efficiently. The correct answer is "b".
23. Out of these operators, which one can be used to get the run time info about an object?
a. Info
b. getInfo
c. getinfoof
d. instanceof
Correct Answer: d
Explanation: The instanceof operator in Java checks the runtime type of an object. The correct answer is "d".
24. Out of these classes, which one allows a user to define their own formatting pattern for time and dates?
a. UsersDateFormat
b. ComplexDateFormat
c. SimpleDateFormat
d. DefinedDateFormat
Correct Answer: c
Explanation: SimpleDateFormat in Java allows custom date and time formatting patterns. The correct answer is "c".
25. Which method can we use in an applet to output a string?
a. transient()
b. drawString()
c. print()
d. display()
Correct Answer: b
Explanation: In Java applets, drawString() (from Graphics) is used to output text on the applet window. The correct answer is "b".
26. The public int start() returns what?
a. the start index of the previous match
b. the start index of the current match
c. the start index of the input string
d. none of the above
Correct Answer: b
Explanation: In Java’s Matcher class, start() returns the start index of the current match. The correct answer is "b".
27. Which one is a superclass of the ContainerEvent class out of the following?
a. ComponentEvent
b. InputEvent
c. ItemEvent
d. WindowEvent
Correct Answer: a
Explanation: ContainerEvent extends ComponentEvent in Java’s AWT event hierarchy. The correct answer is "a".
28. ______ is a superclass of all the Adapter classes.
a. ComponentEvent
b. Apple
c. InputEvent
d. Event
Correct Answer: d
Explanation: In Java AWT, Event (or historically AWTEvent) is a superclass of adapter classes, which simplify event handling. The correct answer is "d" (assuming a typo for Event).
29. Which method in Java generates boolean random values?
a. randomBoolean()
b. nextBoolean()
c. generateBoolean()
d. previousBoolean()
Correct Answer: b
Explanation: The nextBoolean() method in the Random class generates random boolean values. The correct answer is "b".
30. Which class produces objects with respect to their geographical locations?
a. SimpleTimeZone
b. Date
c. Locale
d. TimeZone
Correct Answer: c
Explanation: The Locale class in Java represents geographical, cultural, or regional settings. The correct answer is "c".
31. Which method is used for notifying the observer about the change in the observed object?
a. notify()
b. update()
c. observed()
d. check()
Correct Answer: b
Explanation: In the Observer pattern (Java’s Observer interface), the update() method notifies observers of changes. The correct answer is "b".
32. Which package is used to remotely invoke a method?
a. java.awt
b. java.rmi
c. java.applet
d. java.util
Correct Answer: b
Explanation: The java.rmi (Remote Method Invocation) package enables remote method calls in Java. The correct answer is "b".
33. What are the uses of generics?
a. The generics make a code more readable and optimized
b. The generics make a code faster
c. The generics add stability to a code. They do so by making more bugs detectable at the runtime
d. The generics add stability to a code. They do so by making more bugs detectable at the compile time
Correct Answer: d
Explanation: Generics in Java enhance type safety, catching type-related bugs at compile time. The correct answer is "d".
34. Which mechanism helps in the process of naming as well as visibility control of the classes and their content?
a. Packages
b. Interfaces
c. Object
d. None of the above
Correct Answer: a
Explanation: Packages in Java provide naming and visibility control for classes and their members. The correct answer is "a".
35. The configuration is stored in which of the file database tables:
a. .sql
b. .ora
c. .hbm
d. .dbm
Correct Answer: c
Explanation: In Hibernate (a Java ORM), configuration is stored in .hbm (Hibernate mapping) files. The correct answer is "c".
36. The primary use of Files.lines(Path path) is that it:
a. reads the lines that are from a file as the Stream
b. reads the files that are at the path specified as the String
c. counts the total number of lines for the files at the specified path
d. reads the filenames at the specified path
Correct Answer: a
Explanation: Files.lines(Path path) in Java NIO reads all lines from a file as a Stream<String>. The correct answer is "a".
37. Which keywords for the purpose of upper bound a wildcard?
a. bound
b. stop
c. implements
d. extends
Correct Answer: d
Explanation: In Java generics, extends is used to specify an upper bound for a wildcard (e.g., ? extends Number). The correct answer is "d".
MCQs from PAGE5
38. Out of the following statements, which one is not true about the Java beans?
a. It extends the java.io.Serializable class
b. It implements the java.io.Serializable interface
c. It provides getter and setter methods for its properties
d. It provides us with no argument constructor
Correct Answer: a
Explanation: JavaBeans implement the java.io.Serializable interface, not extend a class. They also provide getters/setters and a no-arg constructor. The correct answer is "a".
39. What does the abbreviation MVC pattern stand for?
a. Model View Class
b. Mock View Class
c. Mock View Controller
d. Model View Control
Correct Answer: d
Explanation: MVC stands for Model-View-Controller, a design pattern in software engineering. The correct answer is "d".
40. The advantage of using the PreparedStatement in Java is:
a. More memory usage
b. Prevents SQL injection
c. Encourages SQL injection
d. Slow performance
Correct Answer: b
Explanation: PreparedStatement prevents SQL injection by using parameterized queries. The correct answer is "b".
41. How does one move from some desired step to another one?
a. logger.error
b. logger.log
c. System.out.println
d. breakpoints
Correct Answer: d
Explanation: Breakpoints in a debugger allow moving between steps during execution. The correct answer is "d".
42. What would happen if the IP Address of the host can't be determined?
a. IO Exception is thrown
b. The system will exit with no message
c. Temporary IP Address will be assigned
d. Unknown Host Exception is thrown
Correct Answer: d
Explanation: In Java, an UnknownHostException is thrown when the IP address of a host cannot be resolved. The correct answer is "d".
43. The storage capacity of a single cookie is:
a. 4095 MegaBytes
b. 4095 bytes
c. 2048 bytes
d. 2048 MegaBytes
Correct Answer: b
Explanation: A single cookie typically has a storage limit of 4095 bytes (4 KB) as per HTTP standards. The correct answer is "b".
44. Which action variable helps in including a file in the JSP?
a. jsp:plugin
b. jsp:include
c. jsp:getProperty
d. jsp:setProperty
Correct Answer: b
Explanation: The jsp:include action in JSP includes a file at runtime. The correct answer is "b".
45. ______ file defines dependency in maven.
a. dependency.xml
b. build.xml
c. version.xml
d. pom.xml
Correct Answer: d
Explanation: The pom.xml (Project Object Model) file in Maven defines dependencies and project configuration. The correct answer is "d".
46. The main difference between AutoCloseable and Closeable is that:
a. AutoCloseable throws IO Exception; Closeable throws Exception
b. AutoCloseable is an implementation; Closeable is a concept
c. AutoCloseable throws Exception; Closeable throws IOException
d. AutoCloseable is a concrete class and Closeable is an interface
Correct Answer: c
Explanation: AutoCloseable throws Exception, while Closeable (which extends AutoCloseable) throws IOException. The correct answer is "c".
Comments
Post a Comment