0% found this document useful (0 votes)
315 views2 pages

BCA Core Java Exam Paper 2025

This document is an examination paper for the Core Java subject for BCA - SEM IV students, scheduled for April/May 2025. It includes multiple-choice questions, programming tasks, and short notes on various Java concepts. The exam is designed to assess students' understanding of Java programming and object-oriented principles.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
315 views2 pages

BCA Core Java Exam Paper 2025

This document is an examination paper for the Core Java subject for BCA - SEM IV students, scheduled for April/May 2025. It includes multiple-choice questions, programming tasks, and short notes on various Java concepts. The exam is designed to assess students' understanding of Java programming and object-oriented principles.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Examination Paper

Subject Code: DIT-491


FACULTY OF TECHNOLOGY
BCA - SEM IV (CBCGS) April/May 2025 Examination
Subject: Core Java
Time: 1 Hour 30 Minutes
Max Marks: 40
Note:
1) All questions are compulsory.
2) All questions carry equal marks.

Q1. Multiple Choice Questions:


1) Which of the following is a valid declaration of an object of class Box?
a) Box obj = new Box(); b) Box obj = new Box; c) obj = new Box(); d) new Box obj;

2) Which of the following is a method having same name as that of its class?
a) finalize b) delete c) class d) constructor

3) What is the numerical range of a char data type in Java?


a) 0 to 256 b) -128 to 127 c) 0 to 65535 d) 0 to 32767

4) Which of these are selection statements in Java?


a) break b) continue c) for() d) if()

5) Which of these operators is used to allocate memory to array variable in Java?


a) Malloc b) Alloc c) New d) New malloc

6) Which of the following is a type of polymorphism in Java Programming?


a) Multiple polymorphism b) Compile time polymorphism
c) Multilevel polymorphism d) External time polymorphism

7) What is the return type of Constructors?


a) int b) float c) void d) none of the mentioned

8) Which operator is used by Java run time implementations to free the memory of an
object when it is no longer needed?
a) delete b) free c) new d) none of the mentioned
Q2.
a) Explain different operators available in Java. (OR)

b) Explain if-else statement with suitable example.

Q3.
a) Define polymorphism. Explain function overloading with suitable example. (OR)

b) Write a program to demonstrate use of ‘object’ and class.

(OR)

Write a program to print reverse of a number.

Q4. Short Notes on any TWO of the following:


a) History of Java
b) Need of OOPS
c) Classes and object
d) Exception handling.

Q5.
a) Which all classes can be overloaded?
a) Constructors b) Methods c) None of the mentioned

b) What type of methods interface can contain by default?


a) abstract b) static c) private d) none of the mentioned

Common questions

Powered by AI

A constructor is a special type of method in Java that is automatically called when an object of a class is created. It has the same name as the class but does not have a return type, not even void. Constructors are used to initialize objects. In contrast, a method with the same name as its class can also exist, but unlike a constructor, it will have a return type and can be called like a regular method within other parts of the code. However, naming a method the same as the class name (while technically legal with a return type) would lead to confusion and is not a recommended practice .

Polymorphism in Java is the ability of an object to take on many forms. The most common use of polymorphism in OOP is when a parent class reference is used to refer to a child class object. Function overloading is a type of compile-time polymorphism where multiple functions are defined with the same name but different parameters, allowing the compiler to determine which function to invoke based on the arguments passed. This demonstrates polymorphism as it provides the ability to perform different operations with the same function name based on input parameters, a characteristic feature of polymorphism .

Constructors in Java do not have a return type because their primary purpose is to initialize a new object of a class. Specifying a return type, even void, would make a constructor appear to behave like a method, contradicting its fundamental role of setting up initial states of an object. Moreover, the Java compiler would not recognize it as a constructor if a return type is provided; it would instead see it as a method definition, leading to incorrect behavior .

In Java, arrays are dynamically allocated on the heap memory using the 'new' operator, which provides flexibility in managing memory usage. The allocation strategy of arrays involves setting aside contiguous memory locations for elements, which ensures efficient memory access due to improved data locality. This leads to performance benefits during iteration processes, although the initial overhead in allocation can be significant. Furthermore, fixed-size allocation during creation can affect efficiency if not accurately anticipated, necessitating careful planning in array management to optimize memory usage and performance .

Java provides 'if-else', 'switch', and loop control statements like 'for', 'while', and 'do-while' for controlling the flow of execution. 'If-else' allows for branching logic based on conditions; 'switch' facilitates multi-way branching using expressions based on the value of variables. Both are selection statements enabling conditional execution of code blocks. They control which portions of code are executed based on boolean conditions, allowing for complex program behavior through simple constructs .

In Java, the 'final' keyword serves as a restrictor, preventing further modification, akin to 'const' in C++, but with nuanced differences. When applied to variables, it prevents reassignment, to methods, it prevents overriding, and to classes, it prevents inheritance. This further enforces immutability and security, traits highly valued in Java's design philosophy for producing stable code. Contrasting this with C++, while 'const' supports such non-modifiability, C++ lacks a native keyword to comprehensively enforce immutability on classes or methods, highlighting Java's robust singular keyword approach as enhancing design modularity and integrity .

In Java, the char data type is a 16-bit Unicode character with a range of 0 to 65535, allowing it to represent all characters in the Unicode set, including letters, digits, and various symbols. This differs from other languages like C, where the char type is typically an 8-bit ASCII character, with a range of only 0 to 255. This design decision in Java reflects its emphasis on internationalization and support for non-ASCII characters as default, setting it apart from languages that primarily support the limited ASCII character set .

Polymorphism facilitates code flexibility and reusability by allowing objects to be interacted with through their base class, enabling the same interface to be used for objects of different types. This reduces coupling and enhances interchangeability across implementations. In Java, polymorphism allows methods to be overridden, enabling a high level of abstraction and design. It simplifies code comprehension and maintenance by permitting generalized methods to operate on objects of different classes using a common interface, promoting dynamic method invocation and expanding software scalability .

The 'new' operator in Java is used to create new objects, allocate memory for them on the heap, and return a reference to that memory. It plays a critical role in memory management by ensuring that when a new object instance is required, the necessary memory space is dynamically allocated. Without 'new', Java wouldn't have the same level of abstraction for creating objects, making manual memory management necessary, which is error-prone and inefficient .

OOP is deemed essential in contemporary development due to its emphasis on modularity, reusability, and abstraction. Java, being an object-oriented language, leverages OOP to enable developers to create more maintainable and scalable code bases through encapsulation (hiding data implementation details), inheritance (promoting code reuse), and polymorphism (enabling flexibility with method use). The modular approach facilitates domain-driven design, allowing for large, complex software solutions to be structured in an organized, logical manner. Additionally, Java's portability and automated garbage collection synergistically enhance OOP models, fostering robust enterprise-level applications .

You might also like