Beruflich Dokumente
Kultur Dokumente
1.1 Introduction
Object-oriented programming (OOP) is a programming paradigm based on the
concept of "objects", which are data structures that contain data, in the form of fields,
often known as attributes; and code, in the form of procedures, often known as
methods. A distinguishing feature of objects is that an object's procedures can access
and often modify the data fields of the object with which they are associated (objects
have a notion of "this"). In object-oriented programming, computer programs are
designed by making them out of objects that interact with one another.There is
significant diversity in object-oriented programming, but most popular languages are
class-based, meaning that objects are instances of classes, which typically also
determines their type.
Many of the most widely used programming languages are multi-paradigm
programming languages that support object-oriented programming to a greater or
lesser degree, typically in combination with imperative, procedural programming.
Significant object-oriented languages include C++, Objective-C, Smalltalk, Delphi,
Java, C#, Perl, Python, Ruby and PHP.
- Object inheritance
functions to the data. These user-defined data types are called "classes", and one
instance of a class is an "object". For example, in a payroll system, a class could be
Manager, and Pat and Jan could be two instances (two objects) of the Manager class.
Encapsulation ensures good code modularity, which keeps routines separate and less
prone to conflict with each other.
-Inheritance
Classes are created in hierarchies, and inheritance lets the structure and methods in
one class pass down the hierarchy. That means less programming is required when
adding functions to complex systems. If a step is added at the bottom of a hierarchy,
only the processing and data associated with that unique step must be added.
Everything else above that step is inherited. The ability to reuse existing objects is
considered a major advantage of object technology.
Chapter 2
Database Connection using JDBC and Exception
Handling
Class Test
{ public static void main()
{ try {
class.forName("Sun.jdbc.odbc.Jdbc:OdbcDriver")
Connection conn = DriverManager.getConnection
("jdbc:odbc:user","username","pass");
}
catch(Class Not found Exception)
{}
}
Complete Program
import java.sql.*;
Class MyDemoCode
{
{ public static void main (String []args)
{
try {
class.forName("Sun.jdbc.odbc.Jdbc:OdbcDriver")
system.outprintln("driver class successfully loaded")
}
try {
Connection conn = DriverManager.getConnection
("jdbc:odbc:user","username","pass");
Statement st = conn.createStatement();
ResultSet.rs = st.executeQuery(Select ename, salary from employee);
while(rs.next())
{ String str = rrs.getString(1);
int amt = rs.getInt(2);
system.out.println(str + \+ + amt);
}
conn.close();
}
catch(SQL Exception ex)
{}
}
}