Object Oriented Programming Using Java - Bca

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Catherine Halcomb
Catherine Halcomb
Community Contributor
Quizzes Created: 1443 | Total Attempts: 6,714,021
| Attempts: 106 | Questions: 25
Please wait...
Question 1 / 25
0 %
0/100
Score 0/100
1. Which of these data type cannot be type parameterized?

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.

Submit
Please wait...
About This Quiz
Object Oriented Programming Using Java - Bca - Quiz

This quiz focuses on Object Oriented Programming using Java, assessing knowledge on GUI packages, access specifiers, interface implementation, and debugging. It's designed for BCA students to enhance their... see moreJava programming skills and understanding of key OOP concepts. see less

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

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.

Submit
3. Which of these Exception handlers cannot be type parameterized?

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.

Submit
4. Which of the following contains both date and time?

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.

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

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.

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

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.

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

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.

Submit
8. Which of the following is an incorrect statement about packages?

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.

Submit
9. What are generic methods?

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.

Submit
10. Which of the following is the correct way of importing an entire package ‘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.

Submit
11. Which attribute is used to specify 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.

Submit
12. Which of these package is used for graphical user interface?

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.

Submit
13. Which of the below is true about java class structure?

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.

Submit
14. Which of the below is false about java coding?

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.

Submit
15. Which of the following cannot be Type parameterized?

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.

Submit
16. Which attribute is used to specify initialization 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.

Submit
17. Which of the following is not introduced with Java 8?

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.

Submit
18. Which one of the following causes memory leak?

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.

Submit
19. What does Files.lines(Path path) do?

Explanation

not-available-via-ai

Submit
20. Which of these instance cannot be created?

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.

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

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.

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

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.

Submit
23. What happens when the value of variable 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.

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

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.

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

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.

Submit
View My Results

Quiz Review Timeline (Updated): Aug 24, 2023 +

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
Cancel
  • All
    All (25)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of these data type cannot be type parameterized?
Which of these keywords is used by a class to use an interface defined...
Which of these Exception handlers cannot be type parameterized?
Which of the following contains both date and time?
What data structure should be used when number of elements is fixed?
Which of these access specifiers can be used for an interface?
What causes the program to exit abruptly and hence its usage should be...
Which of the following is an incorrect statement about packages?
What are generic methods?
Which of the following is the correct way of importing an entire...
Which attribute is used to specify destroy method?
Which of these package is used for graphical user interface?
Which of the below is true about java class structure?
Which of the below is false about java coding?
Which of the following cannot be Type parameterized?
Which attribute is used to specify initialization method?
Which of the following is not introduced with Java 8?
Which one of the following causes memory leak?
What does Files.lines(Path path) do?
Which of these instance cannot be created?
What is debugging an application which runs on another java virtual...
Which is better in terms of performance for iterating an array?
What happens when the value of variable change?
What should the return type of method where there is no return value?
Which of the following is a best practice to measure time taken by a...
Alert!

Advertisement