0% found this document useful (0 votes)
13 views5 pages

Expected Questions For Lab Exam - Java Programming (1)

Expected questions for java lab exam

Uploaded by

fathimabasheerka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
13 views5 pages

Expected Questions For Lab Exam - Java Programming (1)

Expected questions for java lab exam

Uploaded by

fathimabasheerka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

1.

Create a class Student that stores rollno and name with member functions getData() and
putData(). From this derive a class Test with data members mark1 and mark2 and member
functions getMarks() and putMarks(). Create an interface Sports that stores sport’s mark in data
member sportMark. From Test and Sports classes derive the class Result that stores total mark in
data member total. Write a program to test the class.
2. Write an applet program to display a traffic light.

3. Create a class called StringSort which contains a String array as data member. Include member
functions to read an array of strings, to display the array and to sort the array.

4. Write an applet program to display a laughing face.

5. Write a java program which will race an exception called PrimeException when you input a
prime number .

6. Create a package called pack which contains a class Prime with a member function checkPrime()
to check whether a number is prime or not. Create another package called mypack which
contains a class called Matrix and include the following member functions.
To read a matrix, to display the matrix, to find the sum of diagonal elements of the matrix and check
whether the sum is prime or not by accessing the method checkPrime() From Prime class.

7. Create an abstract class called Figure which contains three data members ( length, breadth and
height). Include an abstract method to find the area .Figure class also contains concrete
methods to read the data members and to display them. Derive two classes Rectangle and
Triangle from Figure and override area () to find the area of a rectangle and triangle.
8. Write an applet program to display Olympic rings.
9. Create a class called Matrix which contains a 2d integer array, m & n (order of matrix) as data
members. Include the following member functions
 To read the matrix,
 To display the matrix ,
 Overload a method product () to find the product of two matrices and to multiply each
element of a matrix with a constant value
10. Write an applet program to display the national flag of India.

11. Create a class called Complex which contains two data members X and Y. Include the following
member functions to read a complex number, to display a complex number, to add two complex
numbers and to multiply two complex numbers.

12. Write a swing program to find the sum of two integers (use labels, textboxes and buttons
whenever necessary).

13. Write a java program which will race an exception called NoArgumentException when you run
your program with no command line arguments. If there is any command line arguments display
them.
14. Write an applet program to display a star.

15. Create a class called VectorSample with an integer array as data member and include the
following member functions.
a. -To read an array of elements
b. -To multiply the array by a scalar value
c. -Overload the method sum()
i. -to add a constant value to each of the array elements.
ii. -to add two VectorSample objects
d. -to display the array elements.
16. Write a java application program to print odd and even numbers less than 100 using
multithreading
17. Write a java program which will race an exception called ArmstrongException when you input
an armstrong number .
18. Create a class Student with attributes roll no, name, age and course. If age of student is
not in between 15 and 21 then generate ser-defined exception “AgeNotWithinRangeException”.
If name contains numbers or special symbols raise exception “NameNotValidException”. Define
the two exception classes.

19. Write an applet program to print a message “Happy birthday “ with font Times New Roman, size
32,and color cyan. Also insert a picture in to this applet.

20. Write a java program that implements a multi-thread application that has three threads. First
thread generates a random integer for every one second. second thread computes square of the
number and prints; third thread gives the value of cube of the number..
21. Write a program using swing to accept values in two textboxes and display the results of
mathematical operations in third text box. Use four buttons add, subtract, multiply and divide.
22. Create a class called Matrix which contains a two dimensional integer array,m,n(order of the
matrix) as data members. Include the following member functions
a. To read the matrix
b. To display the matrix
c. To find the transpose of the matrix.
23. Write a Swing program to accept a number then check whether a given number is positive or
negative and display the result in the second textbox?
24. Write a multithreaded program to print odd numbers and even numbers from two different
threads with suitable delay
25. A bank maintains two kinds of accounts - Savings Account and Current Account.The
savings account provides compound interest, deposit and withdrawal facilities. The
current account only provides deposit and withdrawal facilities. Current account holders
should also maintain a minimum balance. If balance falls below this level, a service
charge is imposed. Create a class Account that stores customer name, account number
and type of account. From this derive the classes Curr-acct and Sav-acct. Include the
necessary methods in order to achieve the following tasks.
a. Accept deposit from a customer and update the balance
b. Display the balance.
c. Compute interest and add to balance.
d. Permit withdrawal and update the balance ( Check for the minimum balance,
impose penalty if necessary).
26. Create an interface Department containing attributes deptName and deptHead.it as an
abstract method showData() for printing the attribute.Create a class Hostel containing
hostelname, hostellocation and noofrooms and also have methods readData() and
printData() for reading and printing the details. Then write another class named Student
extending the Hostel class and implementing the Department interface. This class
contains which contains the attributes studname, regno, electivesub and avgmark and use
readData() and showData() for reading and printing the details.
27. Write a swing program to accept a value in a textbox then find the area of a circle and
display the result in the second textbox?
28. Write multithreaded program to print lowercase letters and uppercase letters from two
different threads with suitable delay.
29. Write an applet program to show how to pass a parameter from an applet code?
30. Write a Java Program to calculate the Result. Result should consist of name, seatno, date,
center number and marks of semester three exam. Create a User Defined Exception class
MarksOutOfBoundsException, If Entered marks of any subject is greater than 100 or
less than 0, and then program should create a user defined Exception of type.

31. Write an applet program to draw a house


32. Write a swing program to accept an integer in a textbox then reverse that number and
display the result in the second textbox?
33. Write a Java program which creates a class named 'Employee' having the following
members: Name, Age, Phone number, Address, Salary. It also has a method named 'printSalary(
)' which prints the salary of the Employee. Two classes 'Officer' and 'Manager' inherits the
'Employee' class. The 'Officer' and 'Manager' classes have data members 'specialization' and
'department' respectively. Now, assign name, age, phone number, address and salary to an
officer and a manager by making an object of both of these classes and print the same.
34. Write a swing program to accept a value in a textbox then find the Volume of a sphere
and display the result in the second textbox? (hint :V = 4/3 πr3 )
35. Write a java program to read n numbers and race an exception called NegativeException
when you input a negative number?
36. Write a java program that implements educational hierarchy using inheritance
37. Write a program that creates three threads. First thread displays “Good Morning” every one
second, the second thread displays “Hello” every two seconds and the third thread displays
“Welcome” every three seconds
38. Define class MyDate with members day, month, year. Define default and parameterized
constructors. Accept values from the command line and create a date object. Throw user
defined exceptions – “InvalidDayException” or “InvalidMonthException” if the day and
month are invalid. If the date is valid, display message “Valid date”.
39. Create an interface “CreditCardInterface” with methods to viewCreditAmount, viewPin,
changePin, useCard and payBalance. Create a class Customer (name, card number, pin,
creditAmount – initialized to 0). Implement methods viewCreditAmount, viewPin, changePin and
payBalance of the interface. From Customer, create classes RegularCardHolder (maxCreditLimit)
and GoldCardHolder (String specialPrivileges) and define the remaining methods of the
interface.

40.

You might also like