Object Oriented Programming Using Java - Bca

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 Catherine Halcomb
C
Catherine Halcomb
Community Contributor
Quizzes Created: 1428 | Total Attempts: 5,897,934
Questions: 25 | Attempts: 84

SettingsSettingsSettings
Object Oriented Programming Using Java - Bca - Quiz


Questions and Answers
  • 1. 

    Which of these package is used for graphical user interface?

    • A.

      java.applet

    • B.

      java.awt

    • C.

      java.awt.image

    • D.

      java.io

    Correct Answer
    B. java.awt
    Explanation
    The correct answer is java.awt. The java.awt package is used for creating graphical user interfaces in Java. It provides classes and methods for creating windows, buttons, menus, and other graphical components. The classes in java.awt package are used to handle events, layout components, and perform various other GUI-related tasks.

    Rate this question:

  • 2. 

    Which of these access specifiers can be used for an interface?

    • A.

      Public

    • B.

      Protected

    • C.

      private

    • D.

      All of the mentioned

    Correct Answer
    A. Public
    Explanation
    The access specifier "Public" can be used for an interface. This means that the interface can be accessed and implemented by any class in any package. It allows for maximum accessibility and visibility of the interface.

    Rate this question:

  • 3. 

    Which of these keywords is used by a class to use an interface defined previously?

    • A.

      import

    • B.

      Import

    • C.

      implements

    • D.

      Implements

    Correct Answer
    C. implements
    Explanation
    The "implements" keyword is used by a class to use an interface defined previously. This keyword is used to indicate that a class is implementing an interface and will provide implementations for all the methods defined in that interface. It allows the class to inherit the methods and properties of the interface and ensures that the class follows the contract defined by the interface.

    Rate this question:

  • 4. 

    What is debugging an application which runs on another java virtual machine on another machine?

    • A.

      virtual debugging

    • B.

      remote debugging

    • C.

      machine debugging

    • D.

      compiling debugging

    Correct Answer
    B. remote debugging
    Explanation
    Remote debugging refers to the process of debugging an application that is running on a different machine or Java Virtual Machine (JVM). It allows developers to remotely connect to the JVM on the other machine and analyze and debug the code in real-time. This is particularly useful when troubleshooting issues that can only be replicated on a specific environment or when the application is running on a remote server. Remote debugging enables developers to step through the code, set breakpoints, inspect variables, and understand the flow of execution, ultimately helping them identify and fix bugs efficiently.

    Rate this question:

  • 5. 

    What happens when the value of variable change?

    • A.

      changed value pop on the screen

    • B.

      variable changes are printed in logs

    • C.

      dump of variable changes are printed on the screen on end of execution

    • D.

      variable tab shows variables highlighted when values change

    Correct Answer
    D. variable tab shows variables highlighted when values change
    Explanation
    When the value of a variable changes, the variable tab in the program shows the variables highlighted when their values change. This means that whenever a variable is modified, the variable tab will indicate which variables have been updated by highlighting them. This feature helps the programmer easily track and identify the changes in the values of variables during the execution of the program.

    Rate this question:

  • 6. 

    Which of the following contains both date and time?

    • A.

      java.io.date

    • B.

      java.sql.date

    • C.

      java.util.date

    • D.

      java.util.dateTime

    Correct Answer
    D. java.util.dateTime
    Explanation
    The correct answer is java.util.dateTime because it is the only option that includes both date and time. The other options, java.io.date, java.sql.date, and java.util.date, only represent dates without including the time component.

    Rate this question:

  • 7. 

    Which of the following is the correct way of importing an entire package ‘pkg’?

    • A.

      import pkg.

    • B.

      Import pkg.

    • C.

      import pkg.*

    • D.

      Import pkg.*

    Correct Answer
    C. import pkg.*
    Explanation
    The correct way of importing an entire package 'pkg' is by using the statement "import pkg.*". This statement allows all the classes and interfaces within the 'pkg' package to be accessible in the current code file.

    Rate this question:

  • 8. 

    Which of the following is an incorrect statement about packages?

    • A.

      Package defines a namespace in which classes are stored

    • B.

      A package can contain other package within it

    • C.

      Java uses file system directories to store packages

    • D.

      A package can be renamed without renaming the directory in which the classes are stored

    Correct Answer
    D. A package can be renamed without renaming the directory in which the classes are stored
    Explanation
    A package cannot be renamed without renaming the directory in which the classes are stored. This is because in Java, the package name and the directory structure are closely related. The package name must match the directory structure, and if the package is renamed, the corresponding directory must also be renamed to match the new package name.

    Rate this question:

  • 9. 

    Which attribute is used to specify initialization method?

    • A.

      init

    • B.

      init-method

    • C.

      initialization

    • D.

      initialization-method

    Correct Answer
    B. init-method
    Explanation
    The attribute "init-method" is used to specify the initialization method. This attribute is commonly used in frameworks like Spring to define a method that should be called after the bean is instantiated and its dependencies are injected, allowing for any necessary initialization tasks to be performed.

    Rate this question:

  • 10. 

    Which attribute is used to specify destroy method?

    • A.

      destroy

    • B.

      destroy-method

    • C.

      destruction

    • D.

      destruction-method

    Correct Answer
    B. destroy-method
    Explanation
    The correct answer is "destroy-method". This attribute is used to specify the method that should be called when the bean is being destroyed. It allows for any necessary cleanup or releasing of resources before the bean is removed from the container.

    Rate this question:

  • 11. 

    Which of these instance cannot be created?

    • A.

      Integer instance

    • B.

      Generic class instance

    • C.

      Generic type instance

    • D.

      Collection instances

    Correct Answer
    C. Generic type instance
    Explanation
    A generic type instance cannot be created because a generic type is a template that is used to create specific instances of a class or method. It is not an actual instance itself. Generic types are used to create classes or methods that can work with different types of data, allowing for code reusability. However, the actual instances of these generic types need to be created using specific type arguments.

    Rate this question:

  • 12. 

    Which of these data type cannot be type parameterized?

    • A.

      Array

    • B.

      List

    • C.

      Map

    • D.

      Set

    Correct Answer
    A. Array
    Explanation
    Arrays in most programming languages cannot be type parameterized because they are fixed-size data structures that can only store elements of the same type. Unlike other data structures like lists, maps, and sets, which can be dynamically resized and can store elements of different types, arrays have a fixed length and can only hold elements of a single type. Therefore, arrays cannot be type parameterized.

    Rate this question:

  • 13. 

    What are generic methods?

    • A.

      Generic methods are the methods defined in a generic class

    • B.

      Generic methods are the methods that extend generic class methods

    • C.

      Generic methods are methods that introduce their own type parameters

    • D.

      Generic methods are methods that take void parameters

    Correct Answer
    C. Generic methods are methods that introduce their own type parameters
    Explanation
    Generic methods are methods that introduce their own type parameters. This means that when declaring a generic method, we can specify one or more type parameters that can be used within the method's body. These type parameters allow us to write code that can work with different types, without having to specify the exact type at compile time. This provides flexibility and reusability in our code, as the same method can be used with different types of data.

    Rate this question:

  • 14. 

    Which of these Exception handlers cannot be type parameterized?

    • A.

      catch

    • B.

      throw

    • C.

      throws

    • D.

      all of the mentioned

    Correct Answer
    D. all of the mentioned
    Explanation
    All of the mentioned exception handlers cannot be type parameterized. In Java, catch, throw, and throws are used to handle exceptions. However, unlike other parts of the code where type parameters can be specified, exception handlers cannot be type parameterized. This means that you cannot specify the type of exception that a catch block can handle or the type of exception that a method throws. Therefore, the correct answer is that all of the mentioned exception handlers cannot be type parameterized.

    Rate this question:

  • 15. 

    Which of the following cannot be Type parameterized?

    • A.

      Overloaded Methods

    • B.

      Generic methods

    • C.

      Class methods

    • D.

      Overriding methods

    Correct Answer
    A. Overloaded Methods
    Explanation
    Overloaded methods cannot be type parameterized because type parameters are used to provide flexibility and allow for generic programming. Overloaded methods, on the other hand, are used to provide different implementations of a method with the same name but different parameters. Type parameters are not necessary or applicable in this context, as the method signatures already differentiate between the different overloaded versions of the method.

    Rate this question:

  • 16. 

    What should the return type of method where there is no return value?

    • A.

      Null

    • B.

      Empty collection

    • C.

      Singleton collection

    • D.

      Empty String

    Correct Answer
    B. Empty collection
    Explanation
    The return type of a method where there is no return value should be an empty collection. This means that the method does not return any specific value, but instead returns an empty collection object. This is often used when a method performs some operation or calculation but does not need to return any data. By returning an empty collection, it allows the caller to still iterate over the collection, even though it is empty.

    Rate this question:

  • 17. 

    What data structure should be used when number of elements is fixed?

    • A.

      Array

    • B.

      Array list

    • C.

      Vector

    • D.

      Set

    Correct Answer
    A. Array
    Explanation
    When the number of elements is fixed, the most suitable data structure to use is an array. Arrays have a fixed size and can store a collection of elements of the same data type. They provide constant time access to elements based on their index, making it efficient to retrieve and manipulate data. Additionally, arrays allocate memory in a contiguous manner, allowing for efficient memory management. Therefore, when the number of elements is known and will not change, using an array is the appropriate choice.

    Rate this question:

  • 18. 

    What causes the program to exit abruptly and hence its usage should be minimalistic?

    • A.

      Try

    • B.

      Finally

    • C.

      Exit

    • D.

      Catch

    Correct Answer
    C. Exit
    Explanation
    The "Exit" statement causes the program to exit abruptly and therefore its usage should be minimalistic. When the "Exit" statement is encountered, the program terminates immediately without executing any further code. This can be useful in certain scenarios, such as when an error occurs and the program needs to be stopped immediately. However, excessive use of the "Exit" statement can lead to unexpected program termination and make it difficult to debug and maintain the code. Therefore, it is recommended to use the "Exit" statement sparingly and only when necessary.

    Rate this question:

  • 19. 

    Which one of the following causes memory leak?

    • A.

      Release database connection when querying is complete

    • B.

      Use Finally block as much as possible

    • C.

      Release instances stored in static tables

    • D.

      Not using Finally block often

    Correct Answer
    D. Not using Finally block often
    Explanation
    Not using the Finally block often can cause a memory leak. The Finally block is used to ensure that certain code is executed regardless of whether an exception is thrown or not. If the Finally block is not used, resources such as memory may not be properly released, leading to a memory leak. Therefore, it is important to use the Finally block to ensure proper cleanup and prevent memory leaks.

    Rate this question:

  • 20. 

    Which of the following is a best practice to measure time taken by a process for execution?

    • A.

      System.currentTimeMillis()

    • B.

      System.nanoTime()

    • C.

      System.getCurrentTime()

    • D.

      System.getProcessingTime()

    Correct Answer
    B. System.nanoTime()
    Explanation
    System.nanoTime() is the best practice to measure the time taken by a process for execution. This method returns the current value of the system's high-resolution time source, typically in nanoseconds. It provides a more precise and accurate measurement of time compared to System.currentTimeMillis(), which has a lower resolution. System.getCurrentTime() and System.getProcessingTime() are not valid methods in Java, making them incorrect options.

    Rate this question:

  • 21. 

    Which of the below is true about java class structure?

    • A.

      The class name should start with lowercase

    • B.

      The class should have thousands of lines of code

    • C.

      The class should only contain those attribute and functionality which it should; hence keeping it short

    • D.

      The class attributes and methods should be public

    Correct Answer
    C. The class should only contain those attribute and functionality which it should; hence keeping it short
    Explanation
    The correct answer states that the class should only contain those attributes and functionality which it should, hence keeping it short. This means that a class should only have the necessary attributes and methods that are relevant to its purpose, rather than including unnecessary code. This helps in keeping the class focused and easier to understand, maintain, and reuse. It also promotes better code organization and improves overall code quality.

    Rate this question:

  • 22. 

    Which of the below is false about java coding?

    • A.

      variable names should be short

    • B.

      variable names should be such that they avoid ambiguity

    • C.

      test case method names should be created as english sentences without spaces

    • D.

      class constants should be used when we want to share data between class methods

    Correct Answer
    A. variable names should be short
    Explanation
    In Java coding, variable names should not necessarily be short. It is recommended to use meaningful and descriptive variable names that convey the purpose and content of the variable. Short variable names may lead to confusion and make the code harder to understand and maintain.

    Rate this question:

  • 23. 

    Which is better in terms of performance for iterating an array?

    • A.

      for(int i=0; i

    • B.

      for(int i=99; i>=0; i--)

    • C.

      for(int i=100; i

    • D.

      for(int i=99; i>0; i++)

    Correct Answer
    B. for(int i=99; i>=0; i--)
    Explanation
    The correct answer is "for(int i=99; i>=0; i--)". This is because it starts from the highest index (99) and iterates backwards until it reaches the lowest index (0). This approach is more efficient because it avoids unnecessary checks and calculations, resulting in better performance compared to the other options.

    Rate this question:

  • 24. 

    Which of the following is not introduced with Java 8?

    • A.

      Stream API

    • B.

      Serialization

    • C.

      Spliterator

    • D.

      Lambda Expression

    Correct Answer
    B. Serialization
    Explanation
    Serialization was not introduced with Java 8. Serialization is a concept that allows objects to be converted into a byte stream, which can be stored or transmitted and then reconstructed back into objects. It was introduced in earlier versions of Java and is used for various purposes like object persistence and network communication. Java 8 introduced new features like the Stream API, Spliterator, and Lambda Expressions, which aimed to enhance the functional programming capabilities of the language.

    Rate this question:

  • 25. 

    What does Files.lines(Path path) do?

    • A.

      It reads all the files at the path specified as a String

    • B.

      It reads all the lines from a file as a Stream

    • C.

      It reads the filenames at the path specified

    • D.

      It counts the number of lines for files at the path specified

    Correct Answer
    A. It reads all the files at the path specified as a String

Quiz Review Timeline +

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

  • Current Version
  • Aug 24, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Apr 19, 2020
    Quiz Created by
    Catherine Halcomb
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.