1.
Annotations are comments, notes, explainations, or external remarks attached to a web document.
Correct Answer
A. True
Explanation
Annotations are indeed comments, notes, explanations, or external remarks that are attached to a web document. These annotations can provide additional information or context to the content of the document, helping users better understand the information presented. They can be used for various purposes, such as highlighting important points, clarifying complex concepts, or providing references to related resources. Overall, annotations play a valuable role in enhancing the usability and comprehensibility of web documents.
2.
An Annotation declaration consits of ...........followed by th anotation type.1 choice.
Correct Answer
C. @
Explanation
An Annotation declaration consists of the "@" symbol followed by the annotation type.
3.
Annotations consist of names and have no value associated with it. It consist of the annotaion name and no additional data.
Correct Answer
B. Maker Annotations.
Explanation
The given correct answer is "Maker Annotations". This is because the question states that annotations consist of names and have no value associated with them. Maker Annotations align with this description as they only consist of the annotation name and do not include any additional data or values.
4.
Be Known as single - element, It consists of single value. It can be represented as data= value pair or value within the parenthese.
Correct Answer
C. Single - Value Annotations.
Explanation
The given correct answer is "Single - Value Annotations". Single - Value Annotations are annotations that consist of a single value. They can be represented as a data= value pair or a value within parentheses. Unlike Full Annotations and Maker Annotations, Single - Value Annotations do not have additional information or multiple values associated with them.
5.
This Annotation should not be used on classes, interfaces, package, or constructors. It should be used on method.
Correct Answer
D. @Override
Explanation
The "@Override" annotation is used in Java to indicate that a method is intended to override a method from a superclass or interface. This annotation helps to ensure that the method is correctly overriding the intended method and provides compile-time checking for errors. It is typically used when implementing abstract methods or overriding methods from a superclass.
6.
Which statements are true?- 3 choices
Correct Answer(s)
A. Parameters in annotation can be initialized with arrays of values
D. Parameters in annotation types may defne default values for some members.
E. Parameters in annotation can be initialized to arrays of String values
Explanation
The given answer is correct. Parameters in annotation can be initialized with arrays of values, which means that multiple values can be passed as parameters in an annotation. Parameters in annotation types may define default values for some members, which means that if a parameter is not explicitly provided, it will take the default value defined in the annotation type. Parameters in annotation can be initialized to arrays of String values, which means that the values passed as parameters can be of type String and can be stored in an array.
7.
Which statements are true?- 3 choices
Correct Answer(s)
A. Reflection API induces code into a particular set of classes during execution.
B. Reflection API retrieves the object and its interface for examination.
D. Reflection API is used to get and set values in an array.
Explanation
The given answer is correct. The Reflection API allows code to be dynamically induced into a particular set of classes during execution. It also allows the retrieval of an object and its interface for examination. Additionally, the Reflection API can be used to get and set values in an array.
8.
Which of the following details are not retrieved when a class is examined?
Correct Answer
D. Package Information
Explanation
When a class is examined, the package information is not retrieved. The package information refers to the details about the package in which the class is located, such as the package name and any related documentation. The class name, constructors, class fields, and method information are all retrieved when examining a class.
9.
Create objects using default constructors?
Correct Answer
A. NewInstance() on class
Explanation
The correct answer is "NewInstance() on class". The NewInstance() method is used to create a new instance of a class using its default constructor. This method is part of the Java Reflection API and allows you to dynamically create objects at runtime. By calling NewInstance() on a class, you can create an object without explicitly calling its constructor.
10.
Create objects using prameterized constructors
Correct Answer
D. NewInstance() on Constructor
Explanation
The correct answer is "NewInstance() on Constructor." The NewInstance() method is used to create a new instance of a class using its constructor. It allows you to dynamically create objects at runtime by invoking the constructor with the specified parameters. This method is typically used when you don't know the class name at compile time and need to create objects dynamically based on user input or other runtime conditions.
11.
Retrieve field values using reflection.
Correct Answer
C. GetField() on class
Explanation
The getField() method is used to retrieve the value of a specific field in a class using reflection. It allows access to the field's value regardless of its access modifier (public, private, etc.). This method is commonly used when you want to dynamically access and manipulate the values of fields in a class at runtime.
12.
Assign field values using reflection.
Correct Answer
D. Set()
Explanation
The set() method is used to assign a value to a field using reflection. It allows you to set the value of a field even if it is private or inaccessible through normal means. This method is commonly used when you need to dynamically modify the value of a field at runtime.
13.
Invoke methods using refleftion.
Correct Answer
C. Invoke()
Explanation
The correct answer is "invoke()". The invoke() method is used in reflection to dynamically invoke methods on an object. It allows us to call a method by providing the method name as a string and passing the required arguments. This method is commonly used when the method name or the number of arguments is not known at compile time. Therefore, invoke() is the appropriate choice for invoking methods using reflection.
14.
Which statements are true ?- 3 choices
Correct Answer(s)
A. Array can be identified at runtime.
C. Values of arrays can be retrieved during runtime
D. Values to elements can be assigned to arrays at runtime.
15.
This is matched with a character sequence string. This is called as input Sequence.
Correct Answer
A. Pattern Class
Explanation
The correct answer is "Pattern Class" because the question mentions that the character sequence string is matched with a class, and specifically refers to "Pattern Class" as the answer.
16.
Matcher Class does not have any constructors.
Correct Answer
A. True
Explanation
The statement is true because the Matcher class in Java does not have any constructors. This means that we cannot create an instance of the Matcher class using the new keyword. Instead, we obtain a Matcher object by invoking the matcher() method on a Pattern object. The Matcher class is used for performing match operations on a character sequence using regular expressions.
17.
Tries to match the input sequence against the pattern starting from beginning.
Correct Answer
B. Boolean lookingAt()
Explanation
The method "lookingAt()" is used to determine if the input sequence matches the pattern starting from the beginning. It checks if the pattern is found at the beginning of the input sequence, but does not need to match the entire input sequence. On the other hand, the "find()" method searches for any occurrence of the pattern in the input sequence, not necessarily starting from the beginning. Therefore, the correct answer is "boolean lookingAt()".
18.
Returns the start index of the previous match.
Correct Answer
A. Int start()
Explanation
The method "int start()" is likely a part of a larger program or function that is used to find matches or occurrences of something. The purpose of this method is to return the start index of the previous match that was found. It allows the program to keep track of where the matching pattern or element was found in the string or data being searched. By returning the start index, the program can then perform further operations or calculations based on the location of the match.
19.
Returns the start index of the last match plus one.
Correct Answer
A. Int end()
Explanation
The end() function returns the start index of the last match plus one. This means that it gives the index immediately after the last character of the matched substring.
20.
Which statement are true?- 3 choices.
Correct Answer(s)
A. A regular exp consist of symbols and syntacic elements
B. Pattern and Matcher class are the classes used to perform text processing
D. Find and replace are some of the operations that can be performed by regex
Explanation
A regular expression consists of symbols and syntactic elements, such as metacharacters and quantifiers, which are used to define a pattern for matching strings. The pattern and Matcher class are the classes used in Java to perform text processing with regular expressions. The java.util.regex package consists of these two classes. Find and replace are some of the operations that can be performed using regular expressions. The regex package uses boolean matching to determine if a string matches a given pattern.
21.
The basic form of pattern matching supported by regex- 1 choice.
Correct Answer
A. String Literal
Explanation
The correct answer is "String Literal" because a string literal is a sequence of characters enclosed in double quotation marks. In regex, pattern matching can be done by specifying the exact string literal that needs to be matched. This allows for precise matching of specific strings in a given text or input.
22.
Which are Metacharacters?- 3 choices
Correct Answer(s)
B. { }
C. [ ]
E. *
Explanation
The correct answer is { }, [ ], *.
In regular expressions, metacharacters are special characters that have a symbolic meaning. The curly braces { } are metacharacters used to specify the number of occurrences of a pattern. The square brackets [ ] are used to define a character class, allowing any character within the brackets to match. The asterisk * is a metacharacter used to match zero or more occurrences of the preceding pattern. The hashtag # and the at symbol @ are not metacharacters in this context.
23.
Which are not metacharacter?- 2 choices
Correct Answer(s)
B. & &&
E. ! ,
Explanation
The metacharacters are special characters with a special meaning in regular expressions. In this case, the metacharacters are "&", "&&", and "!". These characters have a specific purpose when used in regular expressions and are not considered regular characters. The other options, "?", ".", "$", "^", "+", "-", and ",", are not metacharacters as they do not have any special meaning in regular expressions and are treated as regular characters.
24.
This is a technique where all characters are matched except those listed. can be represented by inserting the metacharacter "^" at the beginning of character class.
- 1 choice
Correct Answer
B. Negation
Explanation
This technique is called negation, where all characters except those listed are matched. By inserting the metacharacter "^" at the beginning of a character class, it indicates that any character that is not listed should be matched.
25.
The UNION is
Correct Answer
A. A single character class comprising of two or more separate character classes
Explanation
The correct answer is a single character class comprising of two or more separate character classes. This means that the UNION operator allows us to create a single character class by combining multiple separate character classes. This allows us to match any character that belongs to any of the individual character classes within the UNION.
26.
This is used to negate one or more nested character classes1 choice.
Correct Answer
A. Subtraction
Explanation
This answer is correct because the term "subtraction" refers to the use of the negation or exclusion operator within regular expressions. It is used to remove characters or character classes from a larger set. In this context, "nested character classes" refers to character classes that are enclosed within another character class. The use of subtraction allows for the removal of these nested character classes, resulting in a more specific and refined search pattern.
27.
The expression [a-z&&[^abc]]
Correct Answer
A. Matches everything from a->z, except a,b,c.
Explanation
The given regular expression [a-z&&[^abc]] matches any lowercase letter from a to z, excluding the letters a, b, and c. It does not match the letters a, b, or c, but matches any other lowercase letter in the English alphabet.
28.
Represents A digit: [0-9]
Correct Answer
A. \d
Explanation
The correct answer \d represents a digit from 0 to 9. It is a shorthand character class in regular expressions that matches any single digit.
29.
Represents a non - whitespace character: [^\S]
Correct Answer
A. \S
Explanation
The correct answer is \S. In regular expressions, \S represents a non-whitespace character. It matches any character that is not a space, tab, or newline.
30.
Represents a word character:[a-zA-Z_0-9]
Correct Answer
A. \w
Explanation
The correct answer is \w. This regular expression represents a word character, which includes uppercase and lowercase letters, numbers, and the underscore character. It matches any single character that falls into this category.
31.
Which statements are true?- 3 choices.
Correct Answer(s)
A. Simple class are formed by placing characters side by side
C. Negation is a Technique where a metacharacter "^" is inserted at the beginning of character
E. To use an escape construct within a string literal, it must be preceded by a blackslash for the string to compile
Explanation
The first statement is true. Simple classes are formed by placing characters side by side. For example, [abc] represents a character class that includes the characters a, b, and c.
The second statement is true. Ranges define a character class that includes a single value. For example, [a-z] represents a character class that includes all lowercase alphabets.
The third statement is true. Negation is a technique where a metacharacter "^" is inserted at the beginning of a character class. For example, [^a] represents a character class that includes all characters except for the character a.
The fourth statement is not mentioned in the question, so we cannot determine its truthfulness.
The fifth statement is true. To use an escape construct within a string literal, it must be preceded by a backslash for the string to compile. For example, to include a double quote within a string literal, it must be escaped as \".
Therefore, the correct statements are: Simple class are formed by placing characters side by side, Negation is a Technique where a metacharacter "^" is inserted at the beginning of a character, To use an escape construct within a string literal, it must be preceded by a backslash for the string to compile.
32.
Occurs when a Thread is not a state to receive a request that has been made for a specific operation.
Correct Answer
B. IllegalThreadState
Explanation
The correct answer is "IllegalThreadState". This exception occurs when a thread is not in a state to receive a request that has been made for a specific operation. It typically happens when a method is called on a thread that is not in a valid state for that particular method. For example, if a thread is not yet started or has already terminated, and an attempt is made to call a method that is only valid for a running thread, the IllegalThreadState exception will be thrown.
33.
Occurs when Interrupt() or ThreadSleep() are called.
Correct Answer
B. InterruptedException
Explanation
InterruptedException is the correct answer because it is thrown when a thread is waiting, sleeping, or occupied with some other task, and it is interrupted by calling the interrupt() method or when the thread's sleep is interrupted by calling the Thread.sleep() method. This exception is used to handle situations where a thread is waiting or sleeping and needs to be forcefully interrupted.
34.
In a multithreading program two or more threads cannot run concurrently.
Correct Answer
B. False
Explanation
The given statement is false. In a multithreading program, two or more threads can indeed run concurrently. Each thread is an independent sequence of instructions that can be executed simultaneously with other threads. This allows for parallel execution and can lead to improved performance and responsiveness in certain scenarios.
35.
In a multitasking environment two or more processes run concurrently
Correct Answer
A. True
Explanation
In a multitasking environment, two or more processes are able to run concurrently, meaning that they can execute simultaneously. This allows for efficient utilization of system resources and improves overall system performance.
36.
Which Statements are true?- 3 choices
Correct Answer(s)
A. Multithreading facilitates many parts of the same program to run simultaneously.
B. Multithreading requires less overhead than multitasking
D. Multitasking is the ability to execute more than one task or program at the same time by Single Operation System
Explanation
Multithreading allows different parts of the same program to run simultaneously, which can improve efficiency and speed up execution. Multithreading also requires less overhead compared to multitasking, as it involves creating multiple threads within a single process rather than switching between different processes. On the other hand, multitasking refers to the ability to execute multiple tasks or programs at the same time, and it typically requires more overhead compared to multithreading.
37.
This use to find out whether a specific thread is running or not.-1 choice
Correct Answer
B. IsAlive()
Explanation
The correct answer is "isAlive()". This method is used to determine whether a specific thread is currently running or not. It returns a boolean value indicating the thread's status. If the thread is running, the method will return true; otherwise, it will return false. This can be helpful in situations where we need to check the status of a thread and perform certain actions based on its status.
38.
If the Thread is alive, the boolean value True is return. instead of that, return False value.
Correct Answer
A. True
Explanation
The explanation for the given correct answer is that if the thread is alive, it means that the thread is currently running and has not terminated yet. In this case, the boolean value True is returned. However, if the thread is not alive, it means that the thread has either not started or has already terminated. In this case, the boolean value False is returned.
39.
Causes the current Thread to wait until the thread on which it is called terminates.- 1 choice.
Correct Answer
B. Join()
Explanation
The join() method is used to wait for the thread on which it is called to terminate. It causes the current thread to pause its execution and wait until the specified thread completes its execution. This is useful when we want to ensure that certain tasks are completed in a specific order or when we need to wait for a thread to finish before proceeding further in the program.
40.
Join() method Throws InterruptedException if another interrupts it.
Correct Answer
A. True
Explanation
The join() method in Java is used to wait for a thread to die. If another thread interrupts the thread that is waiting with join(), it will throw an InterruptedException. Therefore, the given answer, "True," is correct.
41.
Which statements are true?- 3 choices
Correct Answer(s)
A. The isAlive() method sends a query to inquire, whether the Thread is running or not
C. The isAlive() method forces the current running thread to wait until the thread it is joining with no longer alive
D. The isAlive() method returna a Boolean value
Explanation
The isAlive() method is used to check whether a thread is running or not. It sends a query to inquire about the thread's status. It returns a Boolean value indicating whether the thread is alive or not. Additionally, the isAlive() method can also be used to force the current running thread to wait until the thread it is joining with is no longer alive. This allows for synchronization between threads.
42.
Which Statement are true?- 3 choices
Correct Answer(s)
A. The race conditions can be avoided by using synchronized blocks
B. The race conditions occur due to 2 or more threads sharing same data or reading and writing the share data simultaneously
C. A Synchronized block is nothing but a statement or block of code qualified by synchronized keyword
Explanation
The first statement is true because synchronized blocks can be used to control access to shared data and avoid race conditions. The second statement is true because race conditions occur when multiple threads access and modify shared data simultaneously. The third statement is true because a synchronized block is a block of code that is qualified by the synchronized keyword. However, the fourth statement is false because the lock in a synchronized block is based on the object, not the method. The fifth statement is also false because a lock in a synchronized block only allows one thread to access the code at a time.
43.
This causes a Thread to wait for some other thread to release a resouce
Correct Answer
A. Wait()
Explanation
The wait() method in Java causes a thread to wait for some other thread to release a resource. When a thread encounters the wait() method, it releases the lock it holds and enters a waiting state until another thread notifies it. This mechanism allows threads to synchronize their actions and coordinate their execution. By using wait() and notify() methods, threads can communicate and avoid resource contention issues.
44.
Wait() method can only be invoked only from wthin the synchronised code
Correct Answer
A. True
Explanation
The wait() method in Java is used for inter-thread communication and can only be invoked within synchronized code. When a thread calls the wait() method, it releases the lock it holds and enters a waiting state until another thread notifies it. This is why the wait() method must be called from within synchronized code, as it ensures that the thread calling wait() holds the lock on the object it is waiting on. If the wait() method is called outside synchronized code, it will throw an IllegalMonitorStateException. Therefore, the given answer "True" is correct.
45.
Which Statement are true?- 3 choices.
Correct Answer(s)
A. Java.lang package contains the System class from which you obtain input and output
C. Java.lang package contains class pertaining to strings and buffers
E. Java.lang package is imported by default in all programs
Explanation
The explanation for the given correct answer is that the java.lang package contains the System class, which is used to obtain input and output in Java programs. It also contains classes that pertain to strings and buffers, such as the String and StringBuffer classes. Additionally, the java.lang package is imported by default in all programs, so there is no need to explicitly import it.
46.
Java use primitive data types which are not part of the object hierarchy.
Correct Answer
A. True
Explanation
Java uses primitive data types such as int, float, boolean, etc., which are not part of the object hierarchy. Unlike objects, primitive data types are not represented as instances of a class and do not have any methods or properties associated with them. They are used to store simple values directly in memory, making them more efficient in terms of memory usage and performance compared to objects. Therefore, the statement "Java uses primitive data types which are not part of the object hierarchy" is true.
47.
Which Types are not in Wrapper classes.- 2 choices
Correct Answer(s)
B. Float
E. String
Explanation
The types that are not included in the wrapper classes are float and String. Float is a primitive data type and does not have a corresponding wrapper class. String is not a primitive data type, but it is already a class in Java and does not need a wrapper class. The other options (Integer, Double, and Character) all have corresponding wrapper classes in Java.
48.
Which Statements are true?- 2 choices
Correct Answer(s)
C. Wrapper classes can be used without an import statement
E. Wrapper classes compare values in Objects and be defined in java.lang package
Explanation
Wrapper classes are used to manage primitive values as class. This means that wrapper classes provide a way to use primitive data types as objects. For example, the Integer class can be used to represent an int value as an object.
All primitive data types do not have wrapper class. This statement is false because all primitive data types in Java have corresponding wrapper classes. For example, int has Integer, char has Character, etc.
Wrapper classes can be used without an import statement. This statement is true because the wrapper classes are part of the java.lang package, which is automatically imported in every Java program. Therefore, we can use wrapper classes without explicitly importing them.
Wrapper classes compare values in Objects and be defined in java.lang package. This statement is true because wrapper classes provide methods to compare values and perform other operations on objects. Additionally, all wrapper classes are defined in the java.lang package.
49.
Which statements are true?- 2 choices
Correct Answer(s)
B. Character is a wrapper class for the primitive char data type
E. Integer is a wrapper class for the int data type.
Explanation
Double is not a wrapper class for the floating point value of type float. The correct answer is that Character is a wrapper class for the primitive char data type and Integer is a wrapper class for the int data type.
50.
A Constructor for the Double wrapper class can be written as
Correct Answer
C. Double(double value),Double(String str)
Explanation
The Double wrapper class in Java provides constructors that can accept either a double value or a String representation of a double value. The constructor Double(double value), Double(String str) allows the creation of a Double object by passing in either a double value or a String representation of a double value. This constructor provides flexibility in creating Double objects and allows for easy conversion between different types of representations of double values.