COURSE SUMMARY
Course Title: 
Java Programming Lab
Course Code: 
18CSA285
Year Taught: 
2018
Semester: 
4
Degree: 
Undergraduate (UG)
School: 
School of Engineering
Campus: 
Amritapuri

'Java Programming Lab' is a course offered in the fourth semester of B. C. A. (Bachelor of Computer Applications) program at School of Engineering, Amrita Vishwa Vidyapeetham, Amritapuri.

Unit 1 Java Fundamentals

  • Write a program to print the following triangle of numbers
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
  • Write a simple java application, to print the message , “Welcome to java”
  • Write a program to display the month of a year. Months of the year should be held in an array.
  • Write a program to assign two integer values to X and Y. Using the ‘if’ statement the output of the program should display a message whether X is greater than Y.
  • Write a program to find the area of rectangle.
  • Write a program to list the factorial of the numbers 1 to 10. To calculate the factorial value, use while loop. (Hint Fact of 4 = 4*3*2*1)

Unit 2 OOPs in Java

  • 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.
  • 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 AddSub class 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.
  • 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.
  • Write a java program
    • To find the area and circumference of the circle by accepting the radius from the user.
    • To accept a number and find whether the number is Prime or not
  • Write a java program to create a Student class with following attributes
  • Enrollment No:, Name, Mark of sub1, Mark of sub2, mark of sub3, Total Marks. Total of the three marks must be calculated only when the student passes in all three subjects. The pass mark for each subject is 50. If a candidate fails in any one of the subjects his total mark must be declared as zero. Using this condition write a constructor for this class. Write separate functions for accepting and displaying student details. In the main method create an array of three student objects and display the details.
  • In a college first year class are having the following attributes
  • Name of the class (BCA, BCom, MHA), 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 best Student() 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
  • Write a Java program to define a class called employee with the name and date of appointment. Create ten employee objects as an array and sort them as per their date of appointment. ie, print them as per their seniority.
  • Create a package ‘student.fulltime .BCA‘ in your current working directory
  • Create a default class student in the above package with the following attributes: Name, age, sex.
  • Have methods for storing as well as displaying

Unit 3 Exception Handling

  • Write a program to demonstrate a division by zero exception
  • Write a program to create an user defined exception say Pay Out Of Bounds.
  • Write a small program to catch Negative Array Size Exception. This exception is caused when the array is initialized to negative values.
  • Write a program to handle Null Pointer Exception and use the “finally” method to display a message to the user.

Units 4 and 5 GUI Programming I and II

  • Write a program which create and displays a message on the window
  • Write a program to draw several shapes in the created window
  • Write a program to create an applet and draw grid lines
  • Write a Java program which creates a frame with two buttons father and mother.
    When we click the father button the name of the father, his age and designation must appear.
    When we click mother similar details of mother also appear.
  • Create a frame which displays your personal details with respect to a button click
  • Create a simple applet which reveals the personal information of yours.
  • Write a program to move different shapes according to the arrow key pressed
  • Write a java Program to create a window when we press
    • M or m the window displays Good Morning
    • A or a the window displays Good After Noon
    • E or e the window displays Good Evening
    • N or n the window displays Good Night 
  • Demonstrate the various mouse handling events using suitable example.
  • Write a program to create menu bar and pull down menus.
  • Write a program to explain the multithreading with the use of multiplication table. Three threads must be defined. Each one must create one multiplication table.
  • Write a program to illustrate thread priority.
  • Create a GUI program in java with the following components.
    • A frame with flow layout.
    • Add the following components on to the frame.
      • i. Two Text Field ii. A button with the label display
    • Allow the user to enter data into the textfield
    • When the button is clicked paint the frame by displaying the data entered in the textfield
    • Allow the user to properly close the frame