0% found this document useful (0 votes)
74 views6 pages

BCSL-043 Java Programming Lab Exam

Uploaded by

Rahul Gupta
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)
74 views6 pages

BCSL-043 Java Programming Lab Exam

Uploaded by

Rahul Gupta
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

No.

of Printed Pages :1 BCSL-043 - Set - 1

BACHELOR OF COMPUTER APPLICATIONS (BCA)


(Revised)

Term-End Examination 01208

June, 2016
BCSL-043 - Set - 1 : JAVA PROGRAMMING LAB

Time :1 hour Maximum Marks : 50

Note : (i) There is one compulsory question of 40 marks in this paper.


(ii) 10 marks are for viva-voce.

1. Write a Java program to create an account class. Define appropriate constructor for 40
this class. Define and implement method to display account balance and withdraw
money. Show appropriate message if there is an attempt to withdraw money which
may lead to account balance, less than minimum amount required in account. Make
necessary assumptions required.

BCSL-043 - Set - 1 1
/
No. of Printed Page : 2 BCSL-043/S1

Bachelor of Computer
Application (Revised) (BCA)
Term-End Examination
December ; 2018

JAVA PROGRAMMING LAB

Time : 1 Hour Maximum Marks : 50

9
Note : (i) There is one compulsory question of 40 marks in this paper.

(ii) Rest 10 marks are for viva-voce.

(A-8) P. T. 0.
Ill

1. Create an applet using Java, which take a number as input and display
table of the number. Use appropriate GUI components and layout in
your applet. 40

B CSL-043/S1(R) 500

(A-8)
No. of Printed Pages : 1 I BCSL-043(P)/S1
BACHELOR OF COMPUTER APPLICATIONS (Revised)
(BCA)
Term-End Practical Examination
3 A_ June, 2018

BCSL 043(P)/S1 : JAVA PROGRAMMING LAB


-

Time : 1 Hour Maximum Marks : 50

Note : (i) There is one compulsory question of 40 marks in this paper.


(ii) Rest 10 marks are for viva-voce.

1. Write a Java program to define Account class. Derive Saving_Account class from
Account class. Define appropriate constructors for both the classes. Define the
following methods in Saving_Account class : 40
Display( ) : To display account detail including account number and balance in
account.
Deposit( ) : To deposit money in account.

BCSL-043(P)/S1 1 3,000
No. of Printed Pages : 1 BC SL-043(P)/S3

BACHELOR OF COMPUTER APPLICATIONS (Revised)


(BCA)
Term-End Practical Examination
December, 2017

BCSL-043(P)/S3 : JAVA PROGRAMMING LAB

Time : 1 Hour Maximum Marks : 50

Note : (i) There is one compulsory question of 40 marks in this paper.


(ii) Rest 10 marks are for viva-voce.

1. Create an applet which takes your name and address as input, displays the
name and address in different colors in response to a click of a button. Use
appropriate GUI component in creating the applet. 40

BCSL-043(P)/S3 1 1,000
- No. of Printed Pages : 1 I BCSL-043(P)/S1
BACHELOR OF COMPUTER APPLICATIONS (Revised)
(BCA)
Term-End Practical Examination
CD June, 2017

BCSL-043(P)/S1 : JAVA PROGRAMMING LAB

Time : 1 Hour Maximum Marks : 50

Note : (i) There is one compulsory question of 40 marks in this paper.


(ii) Rest 10 marks are for viva-voce.

1. Write a Java program to implement stack data structure with push( ) and pop( )
methods. Define appropriate constructor, methods and make provision for
exceptions handling in your program. 40

BCSL-043(P)/S1 1 3,000

Common questions

Powered by AI

To implement exception handling in a Java stack data structure, one can use a try-catch block. When implementing the pop() method, it is crucial to check if the stack is empty to avoid removing an element from an empty stack. If it is empty, the method should throw an exception, which is then handled in the catch block. Similarly, for the push() method, appropriate exceptions could be thrown if the stack exceeds its maximum size limit, if any is defined. The specific exception classes should be defined, for instance, EmptyStackException for the pop() case. This ensures that the program can handle errors gracefully without crashing .

To create an applet that reacts to user interactions by displaying names and addresses in different colors, first, GUI components such as JTextField for user input and JButton for user actions are needed. The ActionListener interface can then be implemented to handle button click events. In the actionPerformed method, the name and address can be retrieved from text fields, and JLabel can be used to display them in different colors using the setForeground method. Random color generation or predefined color sets can be utilized for variety .

In creating a Java applet to display a multiplication table, GUI components are crucial for taking user input and displaying output. Components such as JTextField can be used for input, while JLabel can display the multiplication table. Layout management ensures that these components are organized in a user-friendly manner. Layout managers like FlowLayout or GridLayout can be used to arrange components in a sensible way. Proper arrangement improves usability by making sure the applet is intuitive and easy to interact with .

In a Java program class to manage bank account operations with minimum balance restrictions, one would first define an Account class with attributes such as account number, balance, and minimum balance. Appropriate constructors would initialize these attributes. A method for withdrawing money should first check if the withdrawal would bring the balance below the minimum balance. If so, it should display an error message and prevent the withdrawal. An additional method for displaying the account balance could also be included. The Saving_Account class can inherit from the Account class with added functionality specific to savings accounts such as interest calculations .

Inheritance allows the Saving_Account class to reuse code from the Account class, thereby promoting code reusability and reducing redundancy. The Saving_Account inherits properties and methods such as account number, balance, and methods for withdrawing and displaying balance, which are common features of both accounts. Saving_Account can extend these capabilities with additional features specific to savings accounts, like interest calculations or specific withdrawal rules, without altering the original Account class code. This hierarchy aligns well with real-world banking models .

You might also like