Java Programming – Syllabus Topic Explanations
R22-BE-CS | SVCE | Brief Notes for All Units
UNIT III – Interfaces, Exceptions & String Manipulations
Exceptions & Custom Exceptions
An exception is an unexpected event that disrupts normal program flow. Java provides a robust
exception-handling mechanism using try, catch, finally, throw, and throws. You can also create custom
(user-defined) exceptions by extending the Exception class. For example, a NegativeValueException
can be thrown whenever negative values are placed in an array.
String Manipulations
Java's String class provides many built-in methods for text processing: length(), charAt(), substring(),
indexOf(), toUpperCase(), toLowerCase(), trim(), replace(), split(), equals(), and compareTo(). The
StringBuilder and StringBuffer classes are used when frequent modifications to strings are needed, as
they are mutable and more efficient.
Suggested Activities:
• Interface advancedArithmetic: Define an interface with method int divisorSum(int n) and implement it in
class MyCalculator to compute the sum of all divisors of a number.
• Anagram Check: Read two strings and check if they are anagrams by comparing sorted character arrays.
• NegativeValueException: Create a custom exception that is thrown whenever a negative value is added to
an array.
UNIT IV – I/O Streams and Multithreading (9+6 Periods)
Input / Output Basics & Streams
Java I/O is built on the concept of streams – a sequence of data. There are two types: Byte Streams
(handle raw binary data, e.g., FileInputStream / FileOutputStream) and Character Streams (handle text
data in Unicode, e.g., FileReader / FileWriter). The [Link] package provides all necessary classes.
Reading and Writing Console / Files
Console I/O uses [Link] (input) and [Link] (output). For file operations, BufferedReader and
BufferedWriter provide efficient reading/writing by using an internal buffer. Scanner is a convenient class
for parsing console or file input.
Multithreading vs Multitasking
Multitasking allows multiple processes to run concurrently on the OS level. Multithreading is within a
single program – multiple threads share the same memory space and execute simultaneously, making
programs faster and more responsive.
Thread Life Cycle
A thread goes through five states: New (created but not started) → Runnable (ready to run) → Running
(executing) → Blocked/Waiting (waiting for a resource) → Terminated (execution complete). Threads
are created by extending Thread or implementing Runnable.
Creating Threads & Inter-thread Communication
Threads are started using start(), and their logic is placed in run(). Inter-thread communication uses wait(),
notify(), and notifyAll() methods to coordinate between threads sharing resources (producer-consumer
problem). Synchronization prevents race conditions using the synchronized keyword.
Suggested Activities:
• File Copy using File Stream: Use FileInputStream and FileOutputStream to copy contents of one file to
another.
• Multi-threaded Application (3 Threads): Thread 1 generates a random integer every second; Thread 2
computes and prints its square if even; Thread 3 computes and prints its cube if odd.
UNIT V – Java Applet and JavaFX (9+6 Periods)
Java Applet – Introduction
An Applet is a small Java program embedded in a web page and run inside a browser. Key lifecycle
methods are: init() (called once), start() (called when applet starts/resumes), stop() (called when applet is
paused), and destroy() (called before removal). Applets extend the [Link] class and use the
Applet Viewer for testing.
Introduction to JavaFX
JavaFX is the modern Java framework for building rich desktop GUI applications. It replaces Swing and
AWT. A JavaFX app extends Application and overrides start(Stage stage). The Stage is the main window,
and a Scene holds the UI content (node graph).
Events and Controls
Event Basics: JavaFX uses an event-driven model. User actions (clicks, key presses) generate events
handled by EventHandlers or lambda expressions.
Key & Mouse Events: KeyEvent (onKeyPressed, onKeyReleased) and MouseEvent (onMouseClicked,
onMouseMoved) allow interactive applications.
JavaFX Controls
• CheckBox – for boolean on/off options • ToggleButton – stays pressed or unpressed • RadioButton –
mutually exclusive selection in a group • ListView – scrollable list of items • ComboBox – drop-down list •
ChoiceBox – similar to ComboBox but simpler • TextField / TextArea – single-line / multi-line text input •
ScrollPane – adds scrolling to any node
Layouts
JavaFX provides layout panes to arrange controls: HBox (horizontal), VBox (vertical), GridPane
(row-column grid), BorderPane (top/bottom/left/right/center), and FlowPane (wraps items). Layouts
auto-resize with the window.
Menus
A MenuBar holds Menu objects (File, Edit, etc.). Each Menu contains MenuItem entries. Menus support
separators, CheckMenuItems, and RadioMenuItems. ActionEvents are handled with setOnAction() on
each MenuItem.
Suggested Activity:
• Student Management Application using JavaFX: Build a GUI app with JavaFX controls (TextField, ListView,
Buttons), layouts (GridPane/VBox), and menus (Add / Delete / Search students).
Course Outcomes (COs)
CO Statement RBT Level
CO1 Understand the fundamentals of Java programming including variables, data types, control
2 – Understand
structures and methods.
CO2 Apply the concepts of problems classes, objects, packages and inheritance to solve simple
3 – problems.
Apply
CO3 Create Java applications with Interfaces, Strings and Exception Handling mechanism. 6 – Create
CO4 Apply the concepts of streams and multithreaded model to solve real world problems. 3 – Apply
CO5 Apply the concepts of Applet, JavaFX components and controls for developing GUI based
3 –applications.
Apply
RBT Scale: 1 – Remember | 2 – Understand | 3 – Apply | 4 – Analyse | 5 – Evaluate | 6 – Create