NotesB.Sc ITProgramming in Java
BSIT502/BSBC502

Programming in Java Notes

Program:B.Sc IT
Semester:Semester 5
Credits:5
Units:4 Units

Subject Overview

Programming in Java covers OOP fundamentals and Java language basics, classes/inheritance/arrays/interfaces/packages, exception handling and applet/graphics programming, and Java AWT/event handling/I/O. A 5-credit core theory paper.

Unit-wise Syllabus

4 units — open any unit for detailed topic-wise notes, diagrams and important exam questions

  • Object-oriented paradigm basics
  • Java history and features
  • differences from C/C++
  • Java environment
  • simple Java program structure
  • tokens and statements
  • constants/variables/data types
  • operators and expressions
  • decision making/branching/looping statements
ProcessHow Java runs
  1. 1Write .java source
  2. 2javac compiles to bytecode

    .class file

  3. 3JVM loads the class
  4. 4Bytecode verifier checks it
  5. 5JIT compiles and runs it

    Write once, run anywhere

Study guide

This unit introduces Java: the OOP basics, history and features, differences from C and C++, the Java environment, program structure, tokens, constants, variables, data types, operators and expressions and decision-making and looping. Write and run a small program to understand compilation to bytecode.

Read Unit 1 notes
  • Defining classes
  • adding variables and methods
  • creating objects
  • constructors
  • method overloading
  • static members
  • extending a class
  • overriding methods
  • final variables/methods/classes
  • arrays/jagged arrays/strings/vectors
  • defining and implementing interfaces
  • multiple inheritance via interfaces
  • creating and accessing packages
ComparisonOverloading vs overriding
Overloading
Overriding

Where

Same class

Subclass

Signature

Different parameters

Same parameters

Binding

Compile time

Run time

Purpose

Same name, different inputs

Change inherited behaviour

Study guide

You study classes and objects, constructors, method overloading, static members, inheritance, overriding, final, arrays, strings, vectors, interfaces, multiple inheritance through interfaces and packages. Understand why Java uses interfaces instead of multiple inheritance of classes.

Read Unit 2 notes
  • Types of errors and exceptions
  • try/catch/finally blocks
  • throwing custom exceptions
  • applet life cycle
  • creating executable applets
  • passing parameters
  • the Graphics class
  • drawing lines/rectangles/circles/ellipses/arcs/polygons
  • line graphs and bar charts
CycleApplet life cycle
Applet life cycle
1init()
2start()
3paint()
4stop()
5destroy()
  1. 1. init(): Called once to set up
  2. 2. start(): Applet becomes active
  3. 3. paint(): Draws on screen
  4. 4. stop(): Applet leaves view
  5. 5. destroy(): Final clean-up

Study guide

You study errors and exceptions, try, catch and finally, custom exceptions, the applet life cycle, applets, passing parameters, the Graphics class and drawing shapes, line graphs and bar charts. Note that applets are now obsolete in browsers but the concepts of graphics remain useful.

Read Unit 3 notes
  • Java AWT package containers
  • UI components and layouts
  • event delegation approach
  • ActionListener/MouseListener/WindowListener/KeyListener
  • I/O file handling — input/output streams
  • FileInputStream/FileOutputStream
  • reader/writer streams
  • random access files
ProcessEvent delegation model
  1. 1User acts

    Clicks a button

  2. 2Source creates an event object

    ActionEvent

  3. 3Event sent to registered listener
  4. 4Listener method runs

    actionPerformed()

Study guide

You study AWT containers, components and layouts, event delegation, listener interfaces and I/O: streams, file input and output, reader and writer streams and random access files. Build a small GUI application that responds to events.

Read Unit 4 notes

Why Programming in Java Matters

Java is one of the most widely used enterprise languages and the base of Android development, so it opens many job opportunities. It is also common in campus placement coding tests.

How to Prepare for Programming in Java

  • Code every concept and run it; Java is learned by writing programs.
  • Learn exception handling and collections thoroughly.
  • Build a small project, such as a student management application.

Programming in Java: Frequently Asked Questions

Why is Java called platform independent?

Java source code compiles into bytecode that runs on the Java Virtual Machine, which is available for many operating systems.

What is the difference between an interface and an abstract class?

An interface defines method signatures that implementing classes must provide, while an abstract class can also hold implemented methods and state.

Final year of B.Sc IT? Plan your M.Sc IT next.

Build on your B.Sc IT with a 2-year M.Sc IT at SBS and go deeper into AI/ML, cloud and cybersecurity.

Want the Complete Notes & Past Papers?

WhatsApp us and we'll send you the full notes, question banks, and previous year papers for Programming in Java.