Grade "A+" Accredited by NAAC with a CGPA of 3.46
Grade "A+" Accredited by NAAC with a CGPA of 3.46

Programming in JAVA

Course ID
BHCS 03
Level
Undergraduate
Program
B.Sc. CS (Hons.)
Semester
Second
Credits
6.0
Paper Type
Core Course
Method
Lecture & Practical

Unique Paper Code: 32341201

This course adds to the basic programming language skills acquired by the student in earlier semesters. The students are exposed to the advanced features available in Java such as exception handling, file handling, interfaces, packages and GUI programming.

Learning Outcomes:

At the end of the course, students should be able to:

  • Implement Exception Handling and File Handling.
  • Implement multiple inheritance using Interfaces.
  • Logically organize classes and interfaces using packages.
  • Use AWT and Swing to design GUI applications.

Course Contents

Unit 1
Unit 2
Unit 3
Unit 4
Unit 5
Unit 6

Unit 1

Review of Object Oriented Programming and Java Fundamentals: Structure of Java programs, Classes and Objects, Data types, Type Casting, Looping Constructs.

Unit 2

Interfaces Interface basics; Defining, implementing and extending interfaces; Implementing multiple inheritance using interfaces Packages Basics of packages, Creating and accessing packages, System packages, Creating user defined packages.

Unit 3

Exception handling using the main keywords of exception handling: try, catch, throw, throws and finally; Nested try, multiple catch statements, creating user defined exceptions.

Unit 4

File Handling Byte Stream, Character Stream, File I/O Basics, File Operations.

Unit 5

AWT and Event Handling: The AWT class hierarchy, Events, Event sources, Event classes, Event Listeners, Relationship between Event sources and Listeners, Delegation event model, Creating GUI applications using AWT.

Unit 6

Swing Introduction to Swing, Swing vs. AWT, Hierarchy for Swing components, Creating GUI applications using Swing.

 

Practicals

Lab List 1

  1. Design a class Complex having a real part (x) and an imaginary part (y). Provide methods to perform the following on complex numbers:

    1. Add two complex numbers.
    2. Multiply two complex numbers.
    3. toString() method to display complex numbers in the form: x + i y
  2. Create a class TwoDim which contains private members as x and y coordinates in package P1. Define the default constructor, a parameterized constructor and override toString() method to display the co-ordinates. Now reuse this class and in package P2 create another class ThreeDim, adding a new dimension as z as its private member. Define the constructors for the subclass and override toString() method in the subclass also. Write appropriate methods to show dynamic method dispatch. The main() function should be in a package P.
  3. Define an abstract class Shape in package P1. Inherit two more classes: Rectangle in package P2 and Circle in package P3. Write a program to ask the user for the type of shape and then using the concept of dynamic method dispatch, display the area of the appropriate subclass. Also write appropriate methods to read the data. The main() function should not be in any package.
  4. Create an exception subclass UnderAge, which prints “Under Age” along with the age value when an object of UnderAge class is printed in the catch statement. Write a class exception Demo in which the method test() throws UnderAge exception if the variable age passed to it as argument is less than 18. Write main() method also to show working of the program.
  5. Write a program to implement stack. Use exception handling to manage underflow and overflow conditions.
  6. Write a program that copies content of one file to another. Pass the names of the files through command-line arguments.
  7. Write a program to read a file and display only those lines that have the first two characters as ‘//’ (Use try with resources).
  8. Write a program to create an Applet. Create a frame as a child of applet. Implement mouseClicked( ), mouseEntered( ) and mouseExited( ) events for applet. Frame is visible when mouse enters applet window and hidden when mouse exits from the applet window.
  9. Write a program to display a string in frame window with pink color as background.
  10. Write a program to create an Applet that has two buttons named “Red” and “Blue”. When a button is pressed the background color of the applet is set to the color named by the button’s label.

Lab List 2

  1. Create an applet which responds to KEY_TYPED event and updates the status window with message (“Typed character is: X”). Use adapter class for other two events.
  2. Create an applet with two buttons labeled ‘A’ and ‘B’. When button ‘A’ is pressed, it displays your personal information (Name, Course, Roll No, College) and when button ‘B’ is pressed, it displays your CGPA in previous semester.
  3. Write a program that creates a Banner and then creates a thread to scrolls the message in the banner from left to right across the applet’s window..
  4. Rewrite the applet programs using Swing.

Additional Information

Text Books


Schildt, H. (2018). Java: The Complete Reference. 10th edition. McGraw-Hill Education.

Additional Resources


Balaguruswamy E. (2014). Programming with JAVA: A Primer. 5th edition. India: McGraw Hill Education
Horstmann, C. S. (2017). Core Java – Vol. I – Fundamentals (Vol. 10). Pearson Education
Schildt, H., & Skrien, D. (2012). Java Fundamentals – A Comprehensive Introduction. India: McGraw Hill Education.

Teaching Learning Process


Use of ICT tools in conjunction with traditional class room teaching methods
Interactive sessions
Class discussions

Assessment Methods

Written tests, assignments, quizzes, presentations as announced by the instructor in the class.

Keywords

Objects and classes, interfaces, exceptional handling, file handling.

Disclaimer: Details on this page are subject to change as per University of Delhi guidelines. For latest update in this regard please refer to the University of Delhi website here.