Oops Using Java-q2 Group 1

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 Ishtiyaq Khan
I
Ishtiyaq Khan
Community Contributor
Quizzes Created: 1 | Total Attempts: 120
Questions: 20 | Attempts: 123

SettingsSettingsSettings
Oops Using Java-q2 Group 1 - Quiz

.


Questions and Answers
  • 1. 

    The ………………………. loop is especially useful when you process a menu selection.

    • A.

      While

    • B.

      Do-while

    • C.

      For

    • D.

      Switch

    Correct Answer
    B. Do-while
    Explanation
    The do-while loop is especially useful when you process a menu selection because it guarantees that the loop will be executed at least once, regardless of the initial condition. This is important when processing a menu selection because you want to ensure that the user has the opportunity to make a selection before the loop terminates.

    Rate this question:

  • 2. 

    . By using …………………….., you can force immediate termination of loop, bypassing the conditional expression and any remaining code in the body of the loop.

    • A.

      Switch

    • B.

      Break

    • C.

      Continue

    • D.

      Default

    Correct Answer
    B. Break
    Explanation
    By using "break", you can force immediate termination of the loop, bypassing the conditional expression and any remaining code in the body of the loop. This means that when the "break" statement is encountered, the program will exit the loop and continue with the next statement after the loop. It is commonly used to exit a loop early when a certain condition is met or when a specific outcome is desired.

    Rate this question:

  • 3. 

    Which of the following option leads to the portability and security of Java?

    • A.

      Bytecode is executed by JVM

    • B.

      The applet makes the Java code secure and portable

    • C.

      Use of exception handling

    • D.

      Dynamic binding between objects

    Correct Answer
    A. Bytecode is executed by JVM
    Explanation
    Bytecode is executed by JVM leads to the portability and security of Java. The Java programming language is compiled into bytecode, which is a platform-independent code. This means that the bytecode can be executed on any device that has a Java Virtual Machine (JVM) installed, regardless of the underlying hardware or operating system. This portability allows Java programs to run on different platforms without the need for recompilation. Additionally, the JVM provides a secure execution environment by enforcing various security measures, such as sandboxing and access control, to prevent malicious code from causing harm to the system.

    Rate this question:

  • 4. 

    Which of the following is not a Java features?

    • A.

      Dynamic

    • B.

      Architecture Neutral

    • C.

      Use of pointers

    • D.

      Object-oriented

    Correct Answer
    C. Use of pointers
    Explanation
    The use of pointers is not a feature in Java. Pointers are used in programming languages like C and C++ to directly manipulate memory addresses, allowing for more fine-grained control over memory management. However, Java was designed to be a safer and more secure language, and therefore does not support the use of pointers. Instead, Java uses references to objects, which provide a level of abstraction and automatic memory management.

    Rate this question:

  • 5. 

    _____ is used to find and fix bugs in the Java programs.

    • A.

      JVM

    • B.

      JRE

    • C.

      JDK

    • D.

      JDB

    Correct Answer
    D. JDB
    Explanation
    JDB (Java Debugger) is used to find and fix bugs in Java programs. It is a command-line tool provided by the JDK (Java Development Kit) that allows developers to step through their code, set breakpoints, and inspect variables to identify and resolve issues. JDB helps in the debugging process by providing features like stack trace, breakpoints, and variable monitoring, making it an essential tool for Java programmers.

    Rate this question:

  • 6. 

    Which of the following is a valid declaration of a char?

    • A.

      Char ch = '\utea';

    • B.

      Char ca = 'tea';

    • C.

      Char cr = \u0223;

    • D.

      Char cc = '\itea';

    Correct Answer
    A. Char ch = '\utea';
    Explanation
    The given declaration "char ch = '\utea';" is a valid declaration of a char. In Java, a char can be represented by a single character enclosed in single quotes. The '\u' escape sequence is used to represent Unicode characters. In this case, '\utea' represents a Unicode character with the hexadecimal value of 'tea'. Therefore, the declaration is valid.

    Rate this question:

  • 7. 

    What is the return type of the hashCode() method in the Object class?

    • A.

      Object

    • B.

      Int

    • C.

      Long

    • D.

      Void

    Correct Answer
    B. Int
    Explanation
    The return type of the hashCode() method in the Object class is int. This method is used to generate a unique hash code value for an object, which is an integer representation of the object's memory address. It is commonly used in data structures like hash tables to efficiently store and retrieve objects.

    Rate this question:

  • 8. 

    What does the expression float a = 35 / 0 return?

    • A.

      0

    • B.

      Not a Number

    • C.

      Infinity

    • D.

      Run time exception

    Correct Answer
    D. Run time exception
    Explanation
    The expression "float a = 35 / 0" will return a runtime exception. This is because dividing any number by zero is undefined in mathematics, and therefore, it is not allowed in programming. When attempting to divide by zero, a runtime exception is thrown, indicating an error in the program.

    Rate this question:

  • 9. 

    Which of the following for loop declaration is not valid?

    • A.

      For ( int i = 99; i >= 0; i / 9 )

    • B.

      For ( int i = 7; i

    • C.

      For ( int i = 20; i >= 2; - -i )

    • D.

      For ( int i = 2; i

    Correct Answer
    A. For ( int i = 99; i >= 0; i / 9 )
    Explanation
    The given for loop declaration is not valid because the increment or decrement expression is missing. In a for loop, the third part is responsible for updating the loop variable after each iteration. In this case, the expression "i / 9" does not modify the value of "i", which will result in an infinite loop.

    Rate this question:

  • 10. 

    Which method of the Class.class is used to determine the name of a class represented by the class object as a String?

    • A.

      GetClass()

    • B.

      Intern()

    • C.

      GetName()

    • D.

      ToString()

    Correct Answer
    C. GetName()
    Explanation
    The getName() method is used to determine the name of a class represented by the class object as a String. This method returns the fully qualified name of the class, including the package name, in the form of a String.

    Rate this question:

  • 11. 

    In which process, a local variable has the same name as one of the instance variables?

    • A.

      Serialization

    • B.

      Variable Shadowing

    • C.

      Abstraction

    • D.

      Multi-threading

    Correct Answer
    B. Variable Shadowing
    Explanation
    Variable shadowing occurs when a local variable within a certain scope has the same name as an instance variable. This can happen in any process or programming language, not specifically related to serialization, abstraction, or multi-threading. It is a common practice to use variable shadowing to differentiate between local and instance variables and avoid naming conflicts.

    Rate this question:

  • 12. 

    Which package contains the Random class?

    • A.

      Java.util package

    • B.

      Java.lang package

    • C.

      Java.awt package

    • D.

      Java.io package

    Correct Answer
    A. Java.util package
    Explanation
    The Random class is part of the java.util package. This package contains utility classes and interfaces, including those for handling collections, dates, and random number generation. The java.lang package contains fundamental classes and interfaces that are automatically imported into every Java program. The java.awt package is used for creating graphical user interfaces, and the java.io package is used for input and output operations.

    Rate this question:

  • 13. 

    An interface with no fields or methods is known as a ______.

    • A.

      Runnable Interface

    • B.

      Marker Interface

    • C.

      Abstract Interface

    • D.

      CharSequence Interface

    Correct Answer
    B. Marker Interface
    Explanation
    A marker interface is an interface with no fields or methods. It is used to mark classes that implement it as having certain characteristics or capabilities. In this case, an interface with no fields or methods is referred to as a marker interface.

    Rate this question:

  • 14. 

    Which of the following is an immediate subclass of the Panel class?

    • A.

      Applet class

    • B.

      Window class

    • C.

      Frame class

    • D.

      Dialog class

    Correct Answer
    A. Applet class
    Explanation
    The immediate subclass of the Panel class is the Applet class. This means that the Applet class directly extends the Panel class.

    Rate this question:

  • 15. 

    Which option is false about the final keyword?

    • A.

      A final method cannot be overridden in its subclasses.

    • B.

      A final class cannot be extended.

    • C.

      A final class cannot extend other classes.

    • D.

      A final method can be inherited.

    Correct Answer
    C. A final class cannot extend other classes.
    Explanation
    The final keyword is used to restrict the modification of a class, method, or variable. It ensures that the class cannot be extended and the method cannot be overridden in its subclasses. However, a final method can still be inherited by its subclasses. Therefore, the false option is "A final class cannot extend other classes."

    Rate this question:

  • 16. 

    Which of these classes are the direct subclasses of the Throwable class?

    • A.

      RuntimeException and Error class

    • B.

      Exception and VirtualMachineError class

    • C.

      Error and Exception class

    • D.

      IOException and VirtualMachineError class

    Correct Answer
    C. Error and Exception class
    Explanation
    The direct subclasses of the Throwable class are Error and Exception class. This means that both Error and Exception class inherit directly from the Throwable class. The other classes mentioned in the options, such as RuntimeException, VirtualMachineError, and IOException, may be subclasses of either Error or Exception, but they are not direct subclasses of Throwable.

    Rate this question:

  • 17. 

    What do you mean by chained exceptions in Java?

    • A.

      Exceptions occurred by the VirtualMachineError

    • B.

      An exception caused by other exceptions

    • C.

      Exceptions occur in chains with discarding the debugging information

    • D.

      None of the above

    Correct Answer
    B. An exception caused by other exceptions
    Explanation
    Chained exceptions in Java refer to an exception that is caused by another exception. When an exception occurs, it can be caught and then rethrown as a different exception, with the original exception being set as the cause of the new exception. This allows for a more detailed and informative error message, as the chain of exceptions provides a trace of what caused the error. By including the original exception as the cause, developers can easily identify the root cause of the problem and handle it accordingly.

    Rate this question:

  • 18. 

    In which memory a String is stored, when we create a string using new operator?

    • A.

      Stack

    • B.

      String memory

    • C.

      Heap memory

    • D.

      Random storage space

    Correct Answer
    C. Heap memory
    Explanation
    When we create a string using the new operator, the string is stored in the heap memory. The heap memory is a region of the computer's memory where dynamically allocated memory is stored. Strings created using the new operator are stored in the heap because they are dynamically allocated and can be of variable length. This allows for flexibility in memory allocation and deallocation, as the heap memory can be managed by the programmer.

    Rate this question:

  • 19. 

    Which keyword is used for accessing the features of a package?

    • A.

      Package

    • B.

      Import

    • C.

      Extends

    • D.

      Export

    Correct Answer
    B. Import
    Explanation
    The keyword "import" is used for accessing the features of a package. When we want to use classes, interfaces, or other members from a package in our code, we need to import the package using the "import" keyword. This allows us to access and use the classes and other elements defined within the package in our program.

    Rate this question:

  • 20. 

    In java, jar stands for_____.

    • A.

      Java Archive Runner

    • B.

      Java Application Resource

    • C.

      Java Application Runner

    • D.

      None of the above

    Correct Answer
    D. None of the above

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
  • May 09, 2020
    Quiz Created by
    Ishtiyaq Khan
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.