0% found this document useful (0 votes)
33 views1 page

BCA Java Programming Exam Paper 2025

This document outlines the Term Evaluation Examination for the BCA course in Introduction to Java Programming, scheduled for September 2025. It includes various questions on Java concepts such as bytecode, polymorphism, arrays, the String class, and the use of abstract classes and methods. Each question is designed to assess different course outcomes and carries a maximum of 10 marks.

Uploaded by

alexxx9927
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

BCA Java Programming Exam Paper 2025

This document outlines the Term Evaluation Examination for the BCA course in Introduction to Java Programming, scheduled for September 2025. It includes various questions on Java concepts such as bytecode, polymorphism, arrays, the String class, and the use of abstract classes and methods. Each question is designed to assess different course outcomes and carries a maximum of 10 marks.

Uploaded by

alexxx9927
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GEHU/04M/9.1.

3
carapluc
HILL
Esublished
UNIVERSITY
Era
an Act c! the State Legisla!ure ct Uttarakhand
(Zhiniyam Sankhya 12 of 2011)
University under section 2(f) of UGC Act.

Term Evaluation (Odd) Semester Examination September 2025

Roll no.... ......

Name of the Course: BCA


Semester: V
Name of the Paper: Introduction to Java Programming
Paper Code: TBC 501
Time: 1.5 hour Maximum Marks: 50

Note:
(i) Answer all the questions by choosing any one of the sub-questions
(ii) Each question carries 10 marks.

(10 Marks)
QI
Discuss the concept of Java bytecode. How does bytecode enable "write once, run anywhere"
.

(a) (WORA)? Provide a scenario demonstrating the same program running on Windows, Linux, and
macOS. COI

OR

O (b)
Explain the concept of polymorphism in Java. Discuss the differences between compile-time (method
overloading) and runtime (method overriding) polymorphism. Provide examples demonstrating each
type. C03

Q2 (10 Marks)
Write a Java program to declare, initialize, and traverse an array. Explain the difference between single-
(a) dimensional and multi-dimensional arrays. C03

OR
Create a class with local, instance, and static-variables. Write a program to display their values and
(b)
explain the and lifetime of each variable. C02
scope
(10 Marks)
Q3
Explain the String class in Java. Discuss how strings are immutable and the advantages of immutability.
(a) Provide examples of string initialization and concatenation. C03

OR
Write a program demonstrating the use of abstract classes and methods. Explain how abstract classes
enforce method implementation in subclasses. C03

O Q4
Write a Java program to demonstrate the use of blank final variables and static blank final variables.
(10 Marks)

Explain how and when they must be initialized. Also, discuss why blank final variables can only be
(a) assigned once and how static blank final variables belong to the class rather than individual objects.
C02

OR
Discuss the advantages of using the super keyword in object-oriented programming. How does it
(b)
improve code reusability, maintainability, and clarity in inheritance hierarchies? COI
(10 Marks)
Compare interfaces and abstract classes in terms of flexibility, multiple inheritance, and implementation
(a)
requirements. C03
OR
Discuss the advantages and limitations of using the Scanner class for input in Java. Write a program to
(b)
accept marks of five students and calculate the average using Scanner class. C02

Note For the question paper setters:


Question paper should cover all the COs of the course.
• Please specify COs against each question.
Page 1 of 2

Common questions

Powered by AI

The immutability of the String class in Java means once a String object is created, it cannot be altered. This offers security since string constants are shared and reused within the JVM, leading to reduced memory overhead. For example, creating a string `String s = "Hello";` allows for safe sharing. Concatenation (`String s2 = s + " World";`) produces a new string, leaving the original unchanged. This immutability results in safer multithreading and a more reliable caching mechanism internally .

The 'super' keyword in Java allows a subclass to access methods and fields of its superclass, facilitating code reuse. It can call the constructor of the superclass explicitly, ensuring that the inherited part of an object is initialized before the constructor body of a subclass is executed. By using 'super', a subclass can enhance or extend the functionality of its superclass, leading to better organized and more maintainable code. This prevents code duplication and enhances clarity, making it easier to read and maintain the hierarchy .

Abstract classes in Java can define abstract methods, which are methods that only have declarations but no implementations, forcing subclasses to provide concrete implementations. This helps define a framework for subclasses to follow, ensuring a consistent interface. Abstract classes are useful when there are common elements shared by all subclasses but some methods should be customized by the subclasses, like a general animal class with a generic `move()` method that different animals implement differently .

Local variables in Java are defined within methods, constructors, or blocks and are only accessible within these. Their lifetime is limited to the execution of the block they are defined in. Instance variables are non-static fields defined within a class but outside any method. They are tied to a specific instance of a class and available as long as the object exists. Static variables, on the other hand, are shared across all instances of a class and exist for the lifespan of the program. They are declared at the class level using the `static` keyword .

A blank final variable in Java is a final variable that is not initialized during declaration. Such a variable must be assigned exactly once before the constructor completes for instance variables or within a static block for static variables. This ensures its immutability and consistency across usages. Static blank final variables differ because they are associated with the class itself rather than any specific instance. Thus, they are initialized in a static block and the value remains constant for all instances of the class .

Single-dimensional arrays in Java are a list of items of the same type, accessed by a single index. They are used when data can be represented in a single linear list. Multi-dimensional arrays, on the other hand, are arrays of arrays, essentially allowing multiple indices to access data. This is useful for representing more complex data structures like matrices. Single-dimensional arrays are simpler and have less overhead, but multi-dimensional arrays can be more suitable for certain applications, such as when data naturally forms a grid or matrix .

Interfaces in Java offer full abstraction and can be implemented by any class regardless of its hierarchy, thus supporting multiple inheritance by allowing a class to implement multiple interfaces. They only allow method declarations with no body, except default and static methods in Java 8. Abstract classes can have fully implemented methods, allowing a mix of complete and abstract methods, but a class can only inherit from one abstract class due to single inheritance constraints. Interfaces are more flexible in terms of integration, while abstract classes allow for richer functionality through inheritance .

The Scanner class in Java is useful for parsing primitive types and strings using regular expressions, making it convenient for interactive user input, particularly from the console. It simplifies the process of reading keyboard input and flows naturally with its token-based scanning. However, it may be inefficient for large input files due to its CPU-intensive parsing logic. To use it to accept marks from five students and calculate an average, you can loop to read integer inputs, summarize these, and divide by the count for the average .

Java bytecode is a form of intermediate representation that the Java compiler produces. It enables the 'write once, run anywhere' (WORA) capability by being platform-independent. When Java code is compiled, it is transformed into bytecode, which can be executed by any machine with a Java Virtual Machine (JVM). This is because the JVM interprets the bytecode into machine code that is specific to the underlying hardware. For instance, the same Java program can run on Windows, Linux, and macOS without any modifications as long as there is a compatible JVM installed on each system .

Compile-time polymorphism in Java is implemented through method overloading, where multiple methods have the same name but different parameter lists. The method to be executed is determined at compile time. For example, a method `add(int a, int b)` and `add(double a, double b)` are overloaded methods. Runtime polymorphism is achieved via method overriding, where a subclass provides a specific implementation of a method already defined in its superclass. The decision of which method to execute is made at runtime. For instance, if a superclass `Animal` has a method `sound()`, and a subclass `Dog` overrides it, the `sound()` method called on a `Dog` object will execute the subclass’s method .

You might also like