0% found this document useful (0 votes)
7 views8 pages

Java Programming Exam Questions 2023-24

Uploaded by

wizardking8938
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)
7 views8 pages

Java Programming Exam Questions 2023-24

Uploaded by

wizardking8938
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

Roll No. …………………..

BCA-C–404
B. C. A. (Fourth Semester)
EXAMINATION, 2023-24
PROGRAMMING IN JAVA

Time : 212 Hours

Maximum Marks : 60

Note : All questions have to be attempted.

Section—A

1. Multiple Choice Type Questions : 1 each

(i) Which statement is used to compile the


„[Link]‟ file in command prompt ?

(CO1, BL-1)

(a) java [Link]

(b) javac [Link]

(c) cjava [Link]

(d) java compile [Link]

P. T. O.
[2] BCA-C–404

(ii) Which keyword is used to invoke parent class


constructor ? (CO1, BL-1)
(a) this
(b) final
(c) parent
(d) super
(iii) Which area is used by JVM to store object data ?
(CO1, BL-1)
(a) stack area
(b) heap area
(c) method area
(d) None of the above
(iv) What will be the output of the program ?
(CO2, BL-4)
String x = “xyz”;
[Link];
String y = [Link](„Y‟, „y‟);
y = y + “abc”;
[Link](y);
(a) abcXyZ
(b) abcxyz
(c) xyzabc
(d) XyZabc
[3] BCA-C–404

(v) What is the extension of byte code file ?


(CO1, BL-1)
(a) .exe
(b) .java
(c) .byte
(d) .class
(vi) Late Binding is also known as : (CO1, BL-1)
(a) compile time polymorphism
(b) runtime polymorphism
(c) dynamic polymorphism
(d) Both (b) and (c)
(vii) println( ) is a method of which class ?
(CO1, BL-1)
(a) Scanner
(b) System
(c) Print
(d) Print Stream
(viii) What will be the output of the program ?
(CO2, BL-5)
public static void main (String[] args)
{
int[] arr={10,3,4,5}
for(int i=3;i<[Link];i++)
{
If(arr[i]>arr[i+1])
{
}
}
}

P. T. O.
[4] BCA-C–404

(a) nothing will print


(b) compile time error
(c) run time error
(d) None of the above
(ix) What will be the output of the program ?
(CO2, BL-5)
class A
{
public A(int x){ }
}
class B extends A { }
public class test
{
public static void main (String args [])
{
A a = new B();
[Link](“complete”);
}
}
(a) Compile Time Error
(b) Run Time Error
(c) Nothing will print
(d) Complete
[5] BCA-C–404

(x) Which method is used to start the execution of the


thread ? (CO1, BL-1)
(a) run ()
(b) begin ()
(c) getstart ()
(d) start ()
(xi) Which statement is false ? (CO1, BL-1)
(a) JDBC stands for Java database Connectivity
(b) JDBC is a Java API to connect and execute
the query with the database.
(c) It is not part of JavaSE
(d) JDBC API uses JDBC drivers.
(xii) What will be the output ? (CO2, BL-5)
int i = 1, j = 10;
do
{
if(i++> --j) /* Line 4 */
{
continue;
}
} while (i < 5);
[Link](“i = “ + i + “and j = “ + j);
(a) i = 5 and j = 6
(b) i = 6 and j = 5
(c) i = 5 and j = 5
(d) i = 6 and j = 6

P. T. O.
[6] BCA-C–404

2. Write short notes on any four : 3 each


(a) Why we call abstract class is achieve partial
abstraction ? Give an example also. (CO1, BL-3)
(b) Why string is immutable ? Explanation with
example. (CO1, BL-1)
(c) What are the three properties of the final keyword ?
(CO1, BL- 1)
(d) Write a java program to count total number of „is‟
words in a string. (CO1, BL-2)
(e) What are the five steps to connect any java
application with the database using JDBC.
(CO4, BL-4)
Section—B
(Long Answer Type Questions)
3. Attempt any two of the following : 6 each
(a) Explain the internal structure or details of JVM
with proper diagram. (CO1, BL-1)
(b) What is abstraction ? Through which 2 ways we
can achieve abstraction ? What is abstract class ?
Write a java program to create two abstract
methods in a class named as “area () and “volume
Q”. Creating another class named as “Cuboid”
inherits the class in which two abstract methods
define and calculate the area and volume of a
cuboid. (CO5, BL-6)
[7] BCA-C–404

(c) How string builder and string buffer class differs


from string ? Explain any five inbuilt methods of
string buffer class with the help of an example.

(CO2, BL-2)

4. Attempt any two of the following : 6 each

(a) How method overloading differs from overriding ?


Explain with the help of an example. Write a java
program to check how many vowels are in odd
location in a string. (CO2, BL-3)

(b) What is multithreading and why multithreading is


required in java ? Explain the life cycle of a
thread. Write a java program to create a thread
through interface. (CO5, BL-6)

(c) How an Interface achieve fully abstraction and


multiple inheritance ? Explain with an example.
Write a java program to calculate the
multiplication of two matrix. (CO5, BL-6)

5. Attempt any two of the following : 6 each

(a) What is swing in java ? How does java swing


differ from AWT ? Draw the hierarchy of java
swing APT. Write a java program to create one
button named as “click here” and display “java is
a programming language” when user click on
button “click here”. (CO 3, BL-6)

P. T. O.
[8] BCA-C–404

(b) What is an exception ? Why is exception handling


required ? How exception can be handled ? Write
a java program to demonstrate the use of finally
block and throw keyword to handle the exception.

(CO5, BL-6)

(c) What is JDBC ? Explain types of JDBC. Write a


java program to create a table named as employee
with fields empid, empname and salary. Insert
three records inside the employee table.

(CO4, BL-6)

BCA-C–404

Common questions

Powered by AI

Late binding, or dynamic method dispatch, in Java is the mechanism by which a call to an overridden method is resolved at runtime rather than compile-time. It supports polymorphism by allowing a program to decide which method version to execute based on the runtime object. This enables flexibility and enhances code adaptability to future changes without breaking existing functionalities as new subclasses can be added .

Abstraction in Java involves hiding complex implementation details and exposing only essential features of an object. It can be achieved primarily through abstract classes and interfaces. An abstract class provides a base for subclasses to fill in the implementation details, and contains both abstract methods (without body) and concrete methods. Below is a sample abstract class: ```java abstract class Shape { abstract void area(); abstract void volume(); } class Cuboid extends Shape { void area() { /* implementation */ } void volume() { /* implementation */ } } ``` This sample defines an abstract class 'Shape' with abstract methods 'area' and 'volume', allowing subclasses such as 'Cuboid' to implement these methods .

Method overloading in Java occurs when two or more methods in the same class have the same name but different parameters (either in number, types, or order). Method overriding happens when a subclass redefines a method inherited from its superclass with the same signature. For example, in method overloading, you might have methods 'add(int a)' and 'add(int a, int b)'. In method overriding, a superclass method 'display()' might be overridden in the subclass as 'display()' to change its behavior .

Java Swing differs from AWT in that it is built on top of the AWT API but provides a richer set of lightweight components that are platform-independent. Swing components are all written in Java and don't rely on the native system's GUI, making them more versatile and flexible. Java Swing is significant for GUI applications because it provides a consistent look-and-feel across platforms, extensive features such as advanced components (tables, lists, and text areas), and a more sophisticated event handling mechanism .

The 'final' keyword in Java serves various purposes: it prevents a class from being subclassed, stops a method from being overridden, and ensures a variable remains constant (assigned once). The three properties of 'final' are: 1) It can make variables immutable (constant), 2) It can make methods non-overridable, and 3) It can make classes non-inheritable, adding security and predictability to code .

To connect a Java application with a database using JDBC, the following steps are followed: 1) Load the JDBC driver, 2) Establish a connection using the DriverManager, 3) Create a statement using the Connection object, 4) Execute a query using the Statement object to retrieve results, and 5) Close the connections, statements, and result sets to free up resources .

Multithreading in Java allows multiple threads to run concurrently within a program, enhancing performance and efficiency by utilizing CPU resources effectively. It is important for Java applications to perform multiple operations simultaneously, such as user interface responsiveness and background processing. The lifecycle of a thread includes several states: New (thread is created), Runnable (thread is ready to run), Running (currently executing), Blocked/Waiting (waiting for resources or synchronization), and Terminated (completes execution).

String immutability in Java is crucial because it ensures security and efficient memory management by allowing string literals to be reused from the String pool. Immutability prevents malicious alterations and simplifies synchronization in multithreaded environments. When a new String is created, it checks the String pool first, allowing for reduced memory usage as identical strings share the same memory location, leading to memory optimization .

The keyword used to invoke a parent class constructor in Java is 'super'. It is necessary to use 'super' in object-oriented programming to ensure that the parent's constructor is called, which initializes any inherited properties from the parent class before the child class constructor is executed. This is crucial in maintaining the integrity and expected behavior of the base class components within the child class instances .

String in Java is immutable, meaning once a String object is created, its value cannot be changed. On the other hand, StringBuffer and StringBuilder are mutable, allowing modifications such as append, insert, or reverse to occur without creating new objects. StringBuffer is synchronized and thread-safe, whereas StringBuilder is faster but not synchronized. Inbuilt methods of StringBuffer include append(), insert(), delete(), reverse(), and replace().

You might also like