Gaj Quiz For Aptech

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Vietha
V
Vietha
Community Contributor
Quizzes Created: 11 | Total Attempts: 9,614
Questions: 58 | Attempts: 608

SettingsSettingsSettings
Software Quizzes & Trivia

If you like answering specifically designed questions about GAJ quiz for Aptech try out this quiz. It is quite simple and straightforward therefore it will be easy to answer.


Questions and Answers
  • 1. 

    Annotations are comments, notes, explainations, or external remarks attached to a web document.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 2. 

    An Annotation declaration consits of ...........followed by th anotation type.1 choice.

    • A.

      Data Type

    • B.

      Character

    • C.

      @

    • D.

      @@

    Correct Answer
    C. @
    Explanation
    An Annotation declaration consists of the "@" symbol followed by the annotation type.

    Rate this question:

  • 3. 

    Annotations consist of names and have no value associated with it. It consist of the annotaion name and no additional data.

    • A.

      Single - Value Annotations.

    • B.

      Maker Annotations.

    • C.

      Full Annotations.

    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.

    Rate this question:

  • 4. 

    Be Known as single - element, It consists of single value. It can be represented as data= value pair or value within the parenthese.

    • A.

      Full Annotations.

    • B.

      Maker Annotations.

    • C.

      Single - Value Annotations.

    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.

    Rate this question:

  • 5. 

    This Annotation should not be used on classes, interfaces, package, or constructors. It should be used on method.

    • A.

      @Deprecated

    • B.

      @Documented.

    • C.

      @suppressWarnings

    • D.

      @Override

    • E.

      @Interface

    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.

    Rate this question:

  • 6. 

    Which statements are true?- 3 choices

    • A.

      Parameters in annotation can be initialized with arrays of values

    • B.

      Parameters in annotation can have null values

    • C.

      Parameters in annotation are declared as a fields in a class.

    • D.

      Parameters in annotation types may defne default values for some members.

    • E.

      Parameters in annotation can be initialized to arrays of String values

    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.

    Rate this question:

  • 7. 

    Which statements are true?- 3 choices

    • A.

      Reflection API induces code into a particular set of classes during execution.

    • B.

      Reflection API retrieves the object and its interface for examination.

    • C.

      Reflection API cannot manipulate classes.

    • D.

      Reflection API is used to get and set values in an array.

    • E.

      Reflection API cannot be used to retrieve th constructors, methods and fields in a class.

    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.

    Rate this question:

  • 8. 

    Which of the following details are not retrieved when a class is examined?

    • A.

      Class name

    • B.

      Constructors

    • C.

      Class Field

    • D.

      Package Information

    • E.

      Method Information.

    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.

    Rate this question:

  • 9. 

    Create objects using default constructors?

    • A.

      NewInstance() on class

    • B.

      NewInstance() on Constructor

    • C.

      GetField() on class

    • D.

      Set()

    • E.

      Invoke()

    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.

    Rate this question:

  • 10. 

    Create objects using prameterized constructors

    • A.

      Invoke()

    • B.

      GetField() on class

    • C.

      Set()

    • D.

      NewInstance() on Constructor

    • E.

      NewInstance() on class

    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.

    Rate this question:

  • 11. 

    Retrieve field values using reflection.

    • A.

      NewInstance() on Constructor

    • B.

      Invoke()

    • C.

      GetField() on class

    • D.

      Set()

    • E.

      NewInstance() on class

    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.

    Rate this question:

  • 12. 

    Assign field values using reflection.

    • A.

      NewInstance() on Constructor

    • B.

      GetField() on class

    • C.

      Invoke()

    • D.

      Set()

    • E.

      NewInstance() on class

    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.

    Rate this question:

  • 13. 

    Invoke methods using refleftion.

    • A.

      GetField() on class

    • B.

      NewInstance() on Constructor

    • C.

      Invoke()

    • D.

      Set()

    • E.

      NewInstance() on class

    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.

    Rate this question:

  • 14. 

    Which statements are true ?- 3 choices

    • A.

      Array can be identified at runtime.

    • B.

      Arrays can not be created at runtime.

    • C.

      Values of arrays can be retrieved during runtime

    • D.

      Values to elements can be assigned to arrays at runtime.

    • E.

      Array objects cannot be instantiated.

    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.

    • A.

      Pattern Class

    • B.

      Matcher Class

    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.

    Rate this question:

  • 16. 

    Matcher Class does not have any constructors.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 17. 

    Tries to match the input sequence against the pattern starting from beginning.

    • A.

      Boolean find()

    • B.

      Boolean lookingAt()

    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()".

    Rate this question:

  • 18. 

    Returns the start index of the previous match.

    • A.

      Int start()

    • B.

      Int end()

    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.

    Rate this question:

  • 19. 

    Returns the start index of the last match plus one.

    • A.

      Int end()

    • B.

      Int start()

    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.

    Rate this question:

  • 20. 

    Which statement are true?- 3 choices.

    • A.

      A regular exp consist of symbols and syntacic elements

    • B.

      Pattern and Matcher class are the classes used to perform text processing

    • C.

      The java.util.regex package consist of two classes

    • D.

      Find and replace are some of the operations that can be performed by regex

    • E.

      The regex package uses boolean matching

    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.

    Rate this question:

  • 21. 

    The basic form of pattern matching supported by regex- 1 choice.

    • A.

      String Literal

    • B.

      boolean

    • C.

      Character-base

    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.

    Rate this question:

  • 22. 

    Which are Metacharacters?- 3 choices

    • A.

      #

    • B.

      { }

    • C.

      [ ]

    • D.

      @

    • E.

      *

    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.

    Rate this question:

  • 23. 

    Which are not metacharacter?- 2  choices

    • A.

      ?

    • B.

      & &&

    • C.

      . $

    • D.

      ^ + -

    • E.

      ! ,

    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.

    Rate this question:

  • 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

    • A.

      Simple Classes

    • B.

      Negation

    • C.

      Ranges

    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.

    Rate this question:

  • 25. 

    The UNION  is

    • A.

      A single character class comprising of two or more separate character classes

    • B.

      A single character class which matches to characters that are common to all its nested class

    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.

    Rate this question:

  • 26. 

    This is used to negate one or more nested character classes1 choice.

    • A.

      Subtraction

    • B.

      Union

    • C.

      Greedy

    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.

    Rate this question:

  • 27. 

    The expression [a-z&&[^abc]]

    • A.

      Matches everything from a->z, except a,b,c.

    • B.

      Matches 'a','b' and 'c' that is common.

    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.

    Rate this question:

  • 28. 

    Represents A digit: [0-9]

    • A.

      \d

    • B.

      \D

    • C.

      \A

    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.

    Rate this question:

  • 29. 

    Represents a non - whitespace character: [^\S]

    • A.

      \S

    • B.

      \s

    • C.

      \W

    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.

    Rate this question:

  • 30. 

    Represents a word character:[a-zA-Z_0-9]

    • A.

      \w

    • B.

      \W

    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.

    Rate this question:

  • 31. 

    Which statements are true?- 3 choices.

    • A.

      Simple class are formed by placing characters side by side

    • B.

      Ranges define a character class that includes a single value

    • C.

      Negation is a Technique where a metacharacter "^" is inserted at the beginning of character

    • D.

      Subtraction is not used to negate one or more nested character classes

    • E.

      To use an escape construct within a string literal, it must be preceded by a blackslash for the string to compile

    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.

    Rate this question:

  • 32. 

    Occurs when a Thread is not a state to receive a  request that has been made for a specific operation.

    • A.

      InterruptedException

    • B.

      IllegalThreadState

    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.

    Rate this question:

  • 33. 

    Occurs when Interrupt() or ThreadSleep() are called.

    • A.

      IllegalThreadState

    • B.

      InterruptedException

    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.

    Rate this question:

  • 34. 

    In a multithreading program two or more threads cannot run concurrently.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 35. 

    In a multitasking environment two or more processes run concurrently

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 36. 

    Which Statements are true?- 3 choices

    • A.

      Multithreading facilitates many parts of the same program to run simultaneously.

    • B.

      Multithreading requires less overhead than multitasking

    • C.

      Multithreading decreases performance of single processor systems, as it reduces the CPU idle time

    • D.

      Multitasking is the ability to execute more than one task or program at the same time by Single Operation System

    • E.

      Multitasking requires much lower overhead than Multithreading

    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.

    Rate this question:

  • 37. 

    This use to find out whether a specific thread is running or not.-1 choice

    • A.

      Sleep()

    • B.

      IsAlive()

    • C.

      Join()

    • D.

      Wait()

    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.

    Rate this question:

  • 38. 

    If the Thread is alive, the boolean value True is return. instead of that, return False value.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 39. 

    Causes the current Thread to wait until the thread on which it is called terminates.- 1 choice.

    • A.

      Sleep()

    • B.

      Join()

    • C.

      Wait()

    • D.

      IsAlive()

    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.

    Rate this question:

  • 40. 

    Join() method Throws  InterruptedException if another interrupts it.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 41. 

    Which statements are true?- 3 choices

    • A.

      The isAlive() method sends a query to inquire, whether the Thread is running or not

    • B.

      The join() method accomplishes the same task as the sleep() method

    • 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

    • E.

      The join() method doesnot throw an exception when another thread interrupts it

    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.

    Rate this question:

  • 42. 

    Which Statement are true?-  3 choices

    • 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

    • D.

      The Lock in synchronized block is based on the method and not on the object

    • E.

      A lock allows multiple threads to access the code

    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.

    Rate this question:

  • 43. 

    This causes a Thread to wait for some other thread to release a resouce

    • A.

      Wait()

    • B.

      Notify()

    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.

    Rate this question:

  • 44. 

    Wait() method can only be invoked only from wthin the synchronised code

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 45. 

    Which Statement are true?- 3 choices.

    • A.

      Java.lang package contains the System class from which you obtain input and output

    • B.

      Java.lang package has class that contains complex scientific functions

    • C.

      Java.lang package contains class pertaining to strings and buffers

    • D.

      Java.lang package contains the Class class,is the root of the class hierarchy

    • E.

      Java.lang package is imported by default in all programs

    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.

    Rate this question:

  • 46. 

    Java use primitive data types which are not part of the object hierarchy.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 47. 

    Which Types are not in Wrapper classes.- 2 choices

    • A.

      Integer

    • B.

      Float

    • C.

      Double

    • D.

      Character

    • E.

      String

    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.

    Rate this question:

  • 48. 

    Which Statements are true?- 2 choices

    • A.

      Wrapper classes are used to manage primitive values as class

    • B.

      All primitive data types do not have wrapper class

    • C.

      Wrapper classes can be used without an import statement

    • D.

      Wrapper classes compare values in classes

    • E.

      Wrapper classes compare values in Objects and be defined in java.lang package

    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.

    Rate this question:

  • 49. 

    Which statements are true?- 2 choices

    • A.

      Double is a wrapper class for the floating point value of type float

    • B.

      Character is a wrapper class for the primitive char data type

    • C.

      A Constructor for the Byte Wrapper class can be written as Byte(bit value)

    • D.

      A Constructor for the Long wrapper class can be written as Long(lg value)

    • E.

      Integer is a wrapper class for the int data type.

    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.

    Rate this question:

  • 50. 

    A Constructor for the Double  wrapper class can be written  as

    • A.

      Double(Double value),Double(String str)

    • B.

      Double(double value)

    • C.

      Double(double value),Double(String str)

    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.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 30, 2008
    Quiz Created by
    Vietha
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.