You are on page 1of 10

BCA5B07 Java Programming

Course Number: 25
Contact Hours per Week: 6 (3T + 3P)
Number of Credits: 4
Number of Contact Hours: 90 Hrs.
Course Evaluation: Internal: 20 Marks + External: 80 Marks
Unit I [8 T + 4 P] Introduction to OOPS, Characteristics of OOPS, Object
oriented languages, comparison between procedural and object oriented
programming, basic principles of Object Orientation-class, object,
abstraction, encapsulation, inheritance, polymorphism, modularity, and
message passing. Features of object orientation - attributes, state, identity,
operation, behaviour.
Unit II [10 T + 8 P] Introduction to Java: History, Versioning, The Java
Virtual Machine, Byte code, Writing simple java program, Language
Components: Primitive Data Types, Comments, Keywords, literals, The if
Statement, The switch Statement, The for Statement, The while and do
while Statements, The break Statement, The continue Statement, Operators
– Casts and Conversions, Arrays. Introduction to classes and methods,
constructors, Passing Objects to Methods, Method Overloading, Static and
final, The this Reference, finalize, inner and nested classes. Inheriting class,
extends, member access and inheritance, super keyword, Object class.
Dynamic method dispatch, method overriding, abstract class, interface,
packages, import statement.
Unit III [10 T + 10 P] Exceptions, I/O and Threads Input and Output in
Java: The File Class, Standard Streams, Keyboard Input, File I/O Using
Byte Streams, Character Streams, File I/O Using Character Streams -
Buffered Streams, File I/O Using a Buffered Stream, Keyboard Input Using
a Buffered Stream, Writing Text Files. Threads: Threads vs. Processes,
Creating Threads by Extending Thread, Creating Threads by Implementing
Runnable, Advantages of Using Threads, Daemon Threads, Thread States,
Thread Problems, Synchronization. Exceptions: Exception Handling, The
Exception Hierarchy, throws statement, throw statement, Developing user
defined Exception Classes- The finally Block. Unit IV [10 T + 10 P]
Database Connectivity & Applets: Introduction to JDBC : The JDBC
Connectivity Model, Database Programming, Connecting to the Database,
Creating a SQL Query, Executing SQL Queries, Getting the Results,
Updating Database Data, Executing SQL Update/Delete, The Statement
Interface, The ResultSet Interface, ResultSetMetaData. Introduction to GUI
Applications - Applets - Types of Applet, Applet Skeleton, Update method,
repaint Methods, Html Applet tag and passing parameter to applet.
Unit V [10 T + 10 P] Events and GUI Applications: Event Handling: The
Delegation Event Model, Event Classes, Event Listener Interfaces, Adapter
Classes. Java Desktop Applications, Introduction to the AWT, Overview of
the AWT, Structure of the AWT, The AWT hierarchy, Containers,
Components, Canvas, Frame Working with: Color, Font, FontMetrics,
Simple Graphics- Point, line, Rectangle, Polygon, Controls - Button, ,
Checkbox, Choice, , Label, List, Scroll bar, TextArea, TextField, Layout
Manager, MenuBar, Menu, MenuItem , Checkbox MenuItem.
Text Books 1. Herbert Scheldt, Java The Complete Reference, 8th Edition,
Tata McGraw-Hill Edition, ISBN: 9781259002465

Programming language
programming language is the medium of communication between human
and computer systems. It is the set of instructions written in a specific style
(coding) to instruct the computer to perform a specific task.
Types of computer programming languages
There are three types of computer programming languages, they are,
1. Low-level programming languages
2. High-level programming languages
3. Middle-level programming languages
1) Low-level programming languages
These are machine-dependent programming languages such as Binary
(Machine code) and Assembly language. Machine Code (Binary Language)
does not need an interpreter or compiler because the computer understands
these signals directly. The assembly language needs to be converted to
equivalent Binary code so that the computer can understand the instructions
written in Assembly. Assembler is used to convert an assembly code to its
equivalent Binary code. The codes written in such kind of languages are
difficult to write, read, edit, and understand. Also, the programs are not
portable to any other computer system. Low-Level programming language
programs are faster than High-Level programming language programs as
they have fewer keywords, symbols and there is no need to convert it into
Machine Code.
2) High-level programming languages
These are the machine-independent programming languages, which are easy
to write, read, edit, and understand. Languages like Java, Python,
JavaScript, and others (which are very popular now to develop user-end
applications). High-level programming languages have special keywords,
functions, and class libraries. Using these we can easily build a computer
program. The computer does not understand the program written in such
languages directly, As the computer understands only Machine code. So,
Programming language translators are required to convert a high-level
program to its equivalent Machine code. Programming translators are
generally called Compilers and Interpreters.
Features of High-level programming languages,
 Portable (system-independent): The programs written in High-Level
programming languages are independent of the system which means a
program written on one system can run on another system.
 Easy to understand: As these programming languages contain
keywords, functions, class libraries (which are similar to English words), we
can easily understand the meaning of a particular term in that programming
language.
 Easy to code, read, and edit: The programs written in a high-level
programming language are easy to code, read, and edit
3) Middle-level programming languages
Programming languages that have features of both low level and high-level
programming languages come under this category. Hence, we can say
that the programming languages which have features of Low Level as well
as High-Level programming languages known as "Middle Level"
programming language. C programming languages is the best example of
Middle-Level Programming languages as it has features of low level and
high-level programming languages.
Programming language paradigms
1.Procedural Programming
2.Object Oriented Programming
Procedural Programming can be defined as a programming model which is
based upon the concept of calling procedure. Procedures, also known as
routines, subroutines or functions, simply consist of a series of
computational steps to be carried out. During a program’s execution, any
given procedure might be called at any point, including by other
procedures or itself.
Languages used in Procedural Programming:
FORTRAN, ALGOL, COBOL,
BASIC, Pascal and C.
Introduction to OOPS, Characteristics of OOPS, Object oriented languages,
comparison between procedural and object oriented programming,
Introduction to Object Oriented Programming
Object oriented programming can be defined as a programming model
which is based upon the concept of objects. Objects contain data in the
form of attributes and code in the form of methods. In object oriented
programming, computer programs are designed using the concept of
objects that interact with real world. Languages used in Object Oriented
Programming are Java, C,Python, PHP, JavaScript, Perl etc.
Features of Object Oriented programming
 Emphasis on data rather than procedure.
 Programs are divided into entities known as objects.
 Functions that operate on data of an object are tied together in data
structures.
 Data is hidden and cannot be accessed by external functions.
 Objects communicate with each other through functions.
 New data and functions can be easily added whenever necessary.
 Follows bottom up design in program design.
Benefits of OOP
 Through inheritance, we can eliminate redundant code and extend the
use of existing classes.
 The principle of data hiding helps the programmer to build secure
programs that cannot be invaded by code in other parts of the
program.
 It is possible to have multiple instance of objects to coexists without
any interference.
 Object-oriented systems can be easily upgraded from smaller to large
systems.
 Message passing techniques for communication between objects
makes the interface descriptions with external system much simpler.
 Software complexity can be easily managed.
Object-Oriented Languages
 Simula, the first object-oriented programming language.
 Java.
 javascript
 C++
 Python.
 Ruby.
 Perl
Procedural Programming
Procedural Programming can be defined as a programming model which is
derived from structured programming, based upon the concept of calling
procedure. Procedures, also known as routines, subroutines or functions,
simply consist of a series of computational steps to be carried out. During a
program’s execution, any given procedure might be called at any point,
including by other procedures or itself. Languages used in Procedural
Programming are FORTRAN, ALGOL, COBOL,BASIC, Pascal and C.
Comparison between Procedural Programming and Object Oriented
Programming
Procedural Programming Object Oriented Programming
In procedural programming, program In object oriented programming,
is divided into small parts program is divided into small parts
called functions. called objects.
Procedural programming follows top Object oriented programming
down approach. follows bottom up approach.
There is no access specifier in Object oriented programming have
procedural programming. access specifiers like private, public,
protected etc.
Adding new data and function is not Adding new data and function is
easy. easy.
Procedural programming does not Object oriented programming
have any proper way for hiding data provides data hiding so it is more
so it is less secure. secure.
Examples: C, FORTRAN, Pascal, Examples: C++, Java, Python, C#
BASIC etc. etc.
Basic principles of Object Oriented Programming

 Class
 Object
 Abstraction
 Encapsulation
 Inheritance
 Polymorphism
 Modularity
 Message passing
Class
Class is a user defined data type which contains data and methods and
behave like the built-in types of a programming language. Objects are
variables of type class. Once a class has been defined, we can create any
number of objects belonging to that class. Each object is associated with the
data of type class with which they are created. A class is thus a collection of
objects of similar type. Collection of objects is called class. It is a logical
entity. A class can also be defined as a blueprint from which you can create
an individual object. Class doesn't consume any space.
class <classname>
{
data members;
methods
}
Example1
class Student
{
int rollno;
String name;
float total;
void read()
{
}
void disp()
{
}
}
Example2
class Employee
{
Int empid;
String na,dept,
Float sal;
void read()
{
}
void calc()
{
}
void disp()
{
}
}
Object

Instance of a class is known as object. An object contains an address and


takes up some space in memory. Objects are the basic run-time entities in an
object oriented system. They may represent a person, a place, a bank
account, a table of data or any item that the program must handle. Each
object contains data and code to manipulate data.
Student s1=new Student();
Objects have two characteristics: They have states and behaviors.
Example 1:
Object: student1
State: rollno, name, total
Behavior: read, disp
Abstraction
Hiding internal details and showing functionality is known as abstraction.
For example phone call, we don't know the internal processing. Abstraction
refers to the act of representing essential features without including the
background details or explanations. Since classes use the concept of data
abstraction, they are known as Abstract data types (ADT).
Encapsulation
Binding or wrapping up of data(object state) and functions(behavior) into a
single unit (called class) is known as encapsulation. Data encapsulation is
the most striking feature of a class. The data is not accessible to the outside
world and only those functions which are wrapped in the class can access it.
If you are creating class, you are doing encapsulation.
Inheritance
Inheritance is a process by which objects of one class acquire the properties
of objects of another class. In OOP, the concept of inheritance provides the
idea of reusability. This means we can add additional feature to an existing
class without modifying it. This is possible by deriving a new class from
existing one. The new class will have the combined features of both the
classes. The biggest advantage of Inheritance is that the code in base class
need not be rewritten in the child class.

Polymorphism
Polymorphism is another important OOP concept. Polymorphism means the
ability to take more than one form. For e.g. an operation may exhibit
different behavior in different instances. The behavior depends upon the
types of data used in the operation. For e.g. consider the operation of
addition. For two numbers, the operation will generate a sum. If the
operands are strings, then the operation would produce a third string by
concatenation. Polymorphism is extensively used in implementing
inheritance.
Dynamic Binding
Binding refers to the linking of a procedure call to the code to be executed
in response to the call. Dynamic binding means that the code associated
with a given procedure call is not known until the time of the call at run-
time.
Modularity
Modularity is the process of decomposing a problem (program) into a set of
modules so as to reduce the overall complexity of the problem. Modularity
refers to the concept of making multiple modules first and then
linking and combining them to form a complete system. Modularity
enables re-usability and minimizes duplication. The source code for
an object can be written and maintained independently of the source code
for other objects. Once created, an object can be easily passed around inside
the system
Message passing
Message passing is a type of communication between processes. Message
passing is a form of communication used in object-oriented programming.
Communications are completed by the sending of messages to recipients.
An object-oriented program consists of a set of objects that communication
with each other. The process of programming in an object-oriented language
therefore involves the following basic steps.
1. Creating classes that define objects and their behavior.
2. Creating objects from class definitions.
3. Establishing communication among objects.

You might also like