0% found this document useful (0 votes)
5 views3 pages

3rd Sem Java Lab Exam

The document outlines several Java programming tasks, including printing messages, handling exceptions, and performing mathematical operations. It includes specific requirements for creating classes, using arrays, and implementing function overloading. The tasks range from simple applications to more complex programs involving user-defined exceptions and class inheritance.
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)
5 views3 pages

3rd Sem Java Lab Exam

The document outlines several Java programming tasks, including printing messages, handling exceptions, and performing mathematical operations. It includes specific requirements for creating classes, using arrays, and implementing function overloading. The tasks range from simple applications to more complex programs involving user-defined exceptions and class inheritance.
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

1.

Write a simple java application to print the


message “Welcome to java”.

2. Write a program to display the month of a


year. Months of the year should be held in an
array.

3. Write a program to demonstrate a division by


zero exception.

4. Write a program to create a user defined


exception say PayoutOfBounds.

5. Write a java program to add two integers and


two float numbers. When no arguments are
supplied, give a default value to calculate the sum.
Use function overloading.
6. Write a program to perform mathematical
operations. Create a class called AddSub with
methods to add and subtract. Create another class
called MulDiv that extends from AddSubclass to
use the member data of the super class. MulDiv
should have methods to multiply and divide. A
main function should access the methods and
perform the mathematical operations.

7. Write a program with class variable that is


available for all instances of a class. Use static
variable declaration. Observe the changes that
occur in the object’s member variable values.

8. Write a small program to catch Negative Array


Size Exception. This exception is caused when the
array is initialized to negative values.
9. Write a program to handle Null Pointer
Exception and use the “finally” method to display a
message to the user.

10. In a college first year class are having the


following attributes Name of the class (BCA,
[Link], BSc), Name of the staff No of the students
in the class, Array of students in the class. Define a
class called first year with above attributes and
define a suitable constructor. Also write a method
called bestStudent() which process a first-year
object and return the student with the highest
total mark. In the main method define a first-year
object and find the best student of this class.

You might also like