SlideShare a Scribd company logo
PresentedBy
S.Anitha
AP/MCA
VIIMS
CORE JAVA
What is JAVA?
 Java is an object-oriented programming
language developed by James Gosling at Sun
Microsystems and released in 1995.
Old Name : Oak
Green Project (7 members team)
Write Once Run Anywhere (WORA)
JAVA Editions
1.J2SE
2.J2EE
3.J2ME
JAVA Technologies
1. Applets
2. Servlets
3. JSP
4. Swing
5. EJB
6. JDBC
7. Struts
8. Hibernate
JAVA Features
• Pure Object Oriented language.
• Platform independent (JVM)
• Portable – Processor independent
• Multi-threaded – Handling Multiple tas
• JNI
JVM (Java Virtual Machine)
Test.java
class Test
{
public static void main(String b[])
{
System.out.println(“Welcome”);
}
}
How to run a JAVA pgm?
>javac Test.java
o/p: Test.class
>java Test
o/p: Welcome
JDK, BDK, JSDK, JRE, JIT, Hot Java
Different name for java file and class
Sample.java
class Test
{
public static void main(String []a)
{
System.out.println(“Welcome”);
}
}
How to run a JAVA pgm?
>javac Sample.java
o/p: Test.class
>java Test
Welcome
Comment Line
1. Single Line Comment //
2. Multi Line Comment /* */
3.Documentation Comment
/** */
Getting Input
1. DataInputStream
2. BufferedReader
3. Scanner
import java.io.*;
class Test
{
public static void main(String []ar) throws Exception
{
int age;
DataInputStream d = new DataInputStream(System.in);
System.out.println("Enter your Age");
age = Integer.parseInt(d.readLine());
System.out.println("Age:"+ age);
}
}
DataInputStram
Output
D:jpgms>javac sample.java
Note: sample.java uses or overrides a deprecated
API.
Note: Recompile with -Xlint:deprecation for details.
D:jpgms>java Test
Enter your Age
20
Age:20
import java.io.*;
class Test
{
public static void main(String []ar) throws Exception
{
int age;
BufferedReader d = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter your Age");
age = Integer.parseInt(d.readLine());
System.out.println("Age:"+ age);
}
}
import java.util.Scanner;
class Test
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter your rollno");
int rno=sc.nextInt();
System.out.println("Enter your name");
String name=sc.next();
System.out.println("Rollno:"+rno);
System.out.println(" name:"+name);
sc.close();
}
Final, finally, finalizer
• Final
1. Variable (CONSTANT)
final int TOTAL=100;
2. Method (can’t be override)
final int add(){}
3. Class (can’t inherited)
final class Test{ .. }
Finally
Exception Handling
What is Exception? Runtime error
Eg:-
ArrayIndexoutofBounds Exception
int a = new int[10];
a[11]=123;
ClassNotFoundException
Throws  informing the compiler about the
occurrence of an exception (eg:- Questions
without answer)
Try block & Catch block  (eg:- Q & A)
Try block (Q: intimation about the occurrence of
an error to java compiler)
Catch block (A: Solution ie remedy for that
exception)
import java.io.*; //for DataInputStream class
class Test
{
public static void main(String []ar) throws Exception
{
int age;
DataInputStream d = new DataInputStream(System.in);
System.out.println("Enter your Age");
age = Integer.parseInt(d.readLine()); //IOException
System.out.println("Age:"+ age);
}
}
class Test
{
public static void main(String []ar)
{
try
{
int a=100,b=0,c;
c=a/b;
}
catch (Exception e) //ArithmeticException division by zero
{
System.out.println(e);
}
}
}
• try block must be followed by a single or
multiple catch block.
• finally block
Is executed once whether the exception is
raised or not.
 House keeping operations like file closing &
freeing resources
class Test
{
public static void main(String []ar)
{
try
{
int a=100,b=0,c;
c=a/b;
}
catch (Exception e) //ArithmeticException division by zero
{
System.out.println(e);
}
finally
{
System.out.println(“finally block”);
}
}
}
•Finalizer  destructor
Java  Automatic garbage
collected language,
System.gc();
Inheritance
• Deriving a new class from existing class.
• Old class or existing class (Super Class)
• New class or derived class (Sub Class)
Reusability
Types of Inheritance
1. Single Inheritance
2. Multiple Inheritance
3. Hierarchical inheritance
4.MultiLevel Inheritance
5.Hybrid inheritance
1.Single Inheritance
1.Super class
2.Sub Class
Fruit
Apple
2.Multiple Inheritance
(More than one Super class)
Father
Son
Mother
Java doesn’t support Multiple
Inheritance.
?
But we can do Multiple
Inheritance by using interfaces.
3. Hierarchical Inheritance
(More than one Sub class)
iOSAndroid
Mobile OS
Blackberry
4. MultiLevel Inheritance
(Deriving a Sub cls from existing sub cls)
Parent
Grand Parent
Child
5. Hybrid Inheritance
(combination of all types of inheritance)
Single Inheritance
class A
{
static int x=10;
static int y=20;
}
class B extends A
{
public static void main(String[] args)
{
int z=30;
int res=x+y+z;
System.out.println("Result:"+res);
}
}
class Shape
{ int l,b;
}
class Rectangle extends Shape
{
int a;
public int findArea()
{
a = l*b;
return (a);
}
public static void main(String args[])
{
Rectangle r = new Rectangle();
r.l = 10;
r.b = 20;
System.out.println("Area of rectangle is:" + r.findArea());
}
}
Interface
Similar to class but contains only declarations of
variables and methods.
• Methods declared in a interface should
be public and abstract
(final Vs abstract)
• variables declared should be public, static &
final
Interface
Tagging or Markable interface?
An interface with no variables & methods
eg:-
Serializable, Clonnable and Remote interface
Interface pgm
interface P
{
void print();
}
class A implements P
{
public void print()
{ System.out.println("Hello"); }
public static void main(String args[])
{
A obj = new A();
obj.print();
}
}
Multiple Inheritance
class A
{
static int x=10;
}
interface B
{
static int y=20;
}
class C extends A implements B
{
public static void main(String[] args)
{
System.out.println("Multiplication:"+ x*y);
}
Multiple Inheritance
class A
{ }
class B ________________ A
{}
interface I1
{}
class C ________________ B _________________ I
{}
Interface I2 _____________ I1
{}
x extends y
x implements y
Constructor & Destructor
Constructor  A method which is invoked
automatically while creating objects.
Constraints:
• Constructor name should be same as class
name.
• No return value for constructor. (even void)
Types of Constructor:
1. Default Constructor
2. Parameterized Constructor
3. Copy Constructor
4. Dynamic Constructor
Default constructorclass Student
{
int rno;
String name;
void display()
{
System.out.println("Name:"+name);
System.out.println("RollNO:"+rno);
}
public static void main(String args[])
{
Student s1=new Student();//default constructor
s1.display();
}
}
2. Parameterized Constructor
class Student
{
int rno;
String name;
Student(int r,String s)
{
rno=r;
name=s;
}
void display()
{
System.out.println("Name:"+name);
System.out.println("RollNO:"+rno);
}
public static void main(String args[])
{
Student s1=new Student(101,"Sudha");//parameterized constructor
s1.display();
}
Copy Constructor
class Student
{
int rno;
String name;
Student(int r,String s)
{
rno=r;
name=s;
}
Student(Student s) // copy constructor
{
rno=s.rno;
name=s.name;
}
void display()
{
System.out.println("Name:"+name);
System.out.println("RollNO:"+rno);
}
public static void main(String args[])
{
Student s1=new Student(101,"Sudha”);
Student s2 = new Student(s1); //Copy Constructor
s1.display();
s2.display();
}
}
Super keyword
• super can be used to refer immediate parent
class instance variable.
• super can be used to invoke immediate parent
class method.
• super() can be used to invoke immediate
parent class constructor.
class Fruit
{
Fruit()
{
System.out.println("Fruit Class");
}
}
class Apple extends Fruit
{
Apple()
{
super();
System.out.println("Apple class");
}
}
class Test
{
public static void main(String args[])
{ Apple a=new Apple();
}
}
this keywordclass A
{
int a,b;
int add(int x, int y)
{
a=x;
b=y;
return(a+b);
}
}
class B extends A
{
public static void main(String args[])
{
A a=new A();
System.out.println("Added Value:" + a.add(10,20));
}
}
class A
{
int x,y;
int add(int x, int y)
{
this.x=x;
this.y=y;
return(x+y);
}
}
class B extends A
{
public static void main(String args[])
{
A a=new A();
System.out.println("Added Value:" + a.add(10,20));
}
}
Method Overloading
• Same method name with different signatures.
Signature?
• Number and type of arguments.
int add(int a, int b);
int add(int a, int b, int c);
double add(int a, double b);
//Method Overloading
class A
{
int add(int x, int y)
{
return(x+y);
}
int add(int x, int y, int z)
{
return(x+y+z);
}
double add(double x, int y)
{
return(x+y);
}
}
class B extends A
{
public static void main(String args[])
{
A a=new A();
System.out.println("Added Value:" + a.add(10,20));
System.out.println("Added Value:" + a.add(10,20,30));
System.out.println("Added Value:" + a.add(1.2,20));
}
}
Constructor Overloading
• More than one types of constructor used in a
single class.
• Method Overriding
• Same method name with same signature but in
2 different classes namely super class & sub
class.
Overloading Vs Overriding?
// method overriding
class A
{
void show()
{
System.out.println("I am inside super class");
}
}
class B extends A
{
void show()
{
System.out.println("I am inside sub class");
}
}
class Test
{
public static void main(String a[])
{
B b = new B();
b.show();
}
}
Abstract class
• A class which can’t be instantiated.
Ie we can’t create objects for abstract class.
How to create abstract class in Java?
1. Using abstract class.
2. Using at least one abstract method inside a
class.
3. An abstract class contains both abstract & non
abstract methods.
abstract class Bank
{
abstract int getInterest();
}
class SBI extends Bank
{
int getInterest()
{
return 7;
}
}
class TestBank
{
public static void main(String args[])
{
Bank b;
b=new SBI();
System.out.println("Rate of Interest is: "+b.getInterest());
}
}
Package
• grouping of related classes, Interfaces,
methods.
• Default Package ? Language
import java.lang.*; // no need
• Largest Package? awt
Java vs javax
import java.io.*; vs import javax.rmi.*;
• Some Built-in Packages
1) java.lang: defines primitive data types, math
operations
2) java.io: supporting input / output operations.
3) java.util: data structures like Linked List, Date / Time
operations.
4) java.applet: Contains classes for creating Applets.
5) java.awt: graphical user interfaces
6) java.net: networking operations.
Advantages of using packages:
• Preventing naming conflicts
• Easier maintenance
• Controlled access
User defined package
//create a folder mypack and save Mycls.java in mypack
package mypack;
public class Mycls
{
public void getName(String s)
{
System.out.println(s);
}
}
//compile Mycls.java
import mypack.Mycls;
public class Test
{
public static void main(String args[])
{
Mycls m = new Mycls();
m.getName("VIIMS");
}
}
//cd..
//compile Test.java & run
// Output:- VIIMS
//static keyword
import static java.lang.System.*;
class Test
{
public static void main(String b[])
{
out.println("Welcome");
}
}
// Naming conflicts
• import java.util.*;
• import java.sql.*;
Date today ;
//ERROR– java.util.Date or java.sql.Date?
Solution:
java.sql.Date today = new java.sql.Date();
APPLETS
• Small java programs developed for web
applications.
console applications Vs Applets
1. main() 1. No main()
2. No browser 2. needs browser or
appletviewer
Lifecycle of Java Applet
java.applet.Applet class
• public void init(): is used to initialized the Applet.
It is invoked only once.
• public void start(): is invoked after the init()
method or browser is maximized. It is used to
start the Applet.
• public void stop(): is used to stop the Applet. It is
invoked when Applet is stop or browser is
minimized.
• public void destroy(): is used to destroy the
Applet. It is invoked only once.
First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet
{
public void paint(Graphics g)
{
g.drawString("welcome",150,150);
}
}
>javac First.java
Include <applet> tag in 2 ways
1. In java program itself as comment line and
run using appletviewer
>appletviewer First.java
2. As a separate .html file and run using any
browser.
First.java
/*
<applet code="First.class" width="300" height="300">
</applet>
*/
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet
{
public void paint(Graphics g)
{
g.drawString("welcome",150,150);
g.drawLine(20,30,20,300);
}
}
test.html (use any browser)
<html>
<body>
<applet code="First.class" width="300"
height="300">
</applet>
</body>
</html>
JDBC (Java Database Connectivity)
• Front End
• Backend
DBMS Vs RDBMS
• ODBC vs JDBC
SQL
1. DDL
i. Create
ii. Alter
iii. Drop
2. DML
i. Select
ii. Insert
iii. Update
iv. Delete
3. DCL
i. grant
ii. Revoke
4. TCL
i. Commit
ii. Rollback
iii. Save Point
Creating a Tableimport java.sql.*;
class Test
{
public static void main(String a[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("Jdbc:Odbc:stucon");
String qs = "create table student(sname text,rno number)";
PreparedStatement ps = con.prepareStatement(qs);
ps.executeUpdate();
ps.close();
con.close();
}
}
Select Queryimport java.sql.*;
class Test
{
public static void main(String a[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("Jdbc:Odbc:empcon");
String qs = "select * from EMPLOYEE";
PreparedStatement ps = con.prepareStatement(qs);
ResultSet rs = ps.executeQuery();
while(rs.next())
{
System.out.println("Employee No :" + rs.getString(1));
System.out.println("Employee Name:" + rs.getString(2));
System.out.println("Salary Rs :" + rs.getString(3));
}
ps.close();
con.close();
}
}
Thank You

More Related Content

What's hot

Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaSanjeev Tripathi
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Saba Ameer
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
eMexo Technologies
 
core java
core javacore java
core java
Roushan Sinha
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Java Lover
 
Introduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their featuresIntroduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their features
Akash Badone
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
Shalabh Chaudhary
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
atozknowledge .com
 
Core Java
Core JavaCore Java
Core Java
Priyanka Pradhan
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
 
Java Presentation
Java PresentationJava Presentation
Java Presentationaitrichtech
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
Hitesh-Java
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
Madishetty Prathibha
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
icarter09
 
Core java
Core javaCore java
Core java
Shivaraj R
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 

What's hot (20)

Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java I/O
Java I/OJava I/O
Java I/O
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
core java
core javacore java
core java
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Introduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their featuresIntroduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their features
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Core Java
Core JavaCore Java
Core Java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Core java
Core javaCore java
Core java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 

Similar to Core java Essentials

Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Chhom Karath
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Gandhi Ravi
 
sample_midterm.pdf
sample_midterm.pdfsample_midterm.pdf
sample_midterm.pdf
EFRENlazarte2
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
PawanMM
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436
 
Nabil code
Nabil  codeNabil  code
Nabil code
nabildekess
 
Nabil code
Nabil  codeNabil  code
Nabil code
nabildekess
 
Nabil code
Nabil  codeNabil  code
Nabil code
nabildekess
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
RatnaJava
 
Language fundamentals ocjp
Language fundamentals ocjpLanguage fundamentals ocjp
Language fundamentals ocjp
Bhavishya sharma
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
raksharao
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Udayan Khattry
 
Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8
xshyamx
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Palak Sanghani
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab File
Kandarp Tiwari
 

Similar to Core java Essentials (20)

Core java
Core javaCore java
Core java
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
7
77
7
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
sample_midterm.pdf
sample_midterm.pdfsample_midterm.pdf
sample_midterm.pdf
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
 
Language fundamentals ocjp
Language fundamentals ocjpLanguage fundamentals ocjp
Language fundamentals ocjp
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
 
Java 7 New Features
Java 7 New FeaturesJava 7 New Features
Java 7 New Features
 
Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab File
 

More from SRM Institute of Science & Technology, Tiruchirappalli

Mobile App Development
Mobile App DevelopmentMobile App Development
Boolen function representation
Boolen function representationBoolen function representation
Octal to Hexadecimal and Hexadecimal to Octal
Octal to Hexadecimal  and Hexadecimal to OctalOctal to Hexadecimal  and Hexadecimal to Octal
Octal to Hexadecimal and Hexadecimal to Octal
SRM Institute of Science & Technology, Tiruchirappalli
 
Hexadecimal to binary and binary to hexadecimal
Hexadecimal to binary and binary to hexadecimalHexadecimal to binary and binary to hexadecimal
Hexadecimal to binary and binary to hexadecimal
SRM Institute of Science & Technology, Tiruchirappalli
 
Any other numbering system to decimal.docx
Any other numbering system to decimal.docxAny other numbering system to decimal.docx
Any other numbering system to decimal.docx
SRM Institute of Science & Technology, Tiruchirappalli
 
Web services overview
Web services overviewWeb services overview

More from SRM Institute of Science & Technology, Tiruchirappalli (6)

Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
 
Boolen function representation
Boolen function representationBoolen function representation
Boolen function representation
 
Octal to Hexadecimal and Hexadecimal to Octal
Octal to Hexadecimal  and Hexadecimal to OctalOctal to Hexadecimal  and Hexadecimal to Octal
Octal to Hexadecimal and Hexadecimal to Octal
 
Hexadecimal to binary and binary to hexadecimal
Hexadecimal to binary and binary to hexadecimalHexadecimal to binary and binary to hexadecimal
Hexadecimal to binary and binary to hexadecimal
 
Any other numbering system to decimal.docx
Any other numbering system to decimal.docxAny other numbering system to decimal.docx
Any other numbering system to decimal.docx
 
Web services overview
Web services overviewWeb services overview
Web services overview
 

Recently uploaded

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

Core java Essentials

  • 2. What is JAVA?  Java is an object-oriented programming language developed by James Gosling at Sun Microsystems and released in 1995. Old Name : Oak Green Project (7 members team) Write Once Run Anywhere (WORA)
  • 4. JAVA Technologies 1. Applets 2. Servlets 3. JSP 4. Swing 5. EJB 6. JDBC 7. Struts 8. Hibernate
  • 5. JAVA Features • Pure Object Oriented language. • Platform independent (JVM) • Portable – Processor independent • Multi-threaded – Handling Multiple tas • JNI
  • 6. JVM (Java Virtual Machine)
  • 7. Test.java class Test { public static void main(String b[]) { System.out.println(“Welcome”); } }
  • 8. How to run a JAVA pgm? >javac Test.java o/p: Test.class >java Test o/p: Welcome JDK, BDK, JSDK, JRE, JIT, Hot Java
  • 9. Different name for java file and class Sample.java class Test { public static void main(String []a) { System.out.println(“Welcome”); } }
  • 10. How to run a JAVA pgm? >javac Sample.java o/p: Test.class >java Test Welcome
  • 11. Comment Line 1. Single Line Comment // 2. Multi Line Comment /* */ 3.Documentation Comment /** */
  • 12. Getting Input 1. DataInputStream 2. BufferedReader 3. Scanner
  • 13. import java.io.*; class Test { public static void main(String []ar) throws Exception { int age; DataInputStream d = new DataInputStream(System.in); System.out.println("Enter your Age"); age = Integer.parseInt(d.readLine()); System.out.println("Age:"+ age); } }
  • 14. DataInputStram Output D:jpgms>javac sample.java Note: sample.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. D:jpgms>java Test Enter your Age 20 Age:20
  • 15. import java.io.*; class Test { public static void main(String []ar) throws Exception { int age; BufferedReader d = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter your Age"); age = Integer.parseInt(d.readLine()); System.out.println("Age:"+ age); } }
  • 16. import java.util.Scanner; class Test { public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.println("Enter your rollno"); int rno=sc.nextInt(); System.out.println("Enter your name"); String name=sc.next(); System.out.println("Rollno:"+rno); System.out.println(" name:"+name); sc.close(); }
  • 17. Final, finally, finalizer • Final 1. Variable (CONSTANT) final int TOTAL=100; 2. Method (can’t be override) final int add(){} 3. Class (can’t inherited) final class Test{ .. }
  • 18. Finally Exception Handling What is Exception? Runtime error Eg:- ArrayIndexoutofBounds Exception int a = new int[10]; a[11]=123; ClassNotFoundException
  • 19. Throws  informing the compiler about the occurrence of an exception (eg:- Questions without answer) Try block & Catch block  (eg:- Q & A) Try block (Q: intimation about the occurrence of an error to java compiler) Catch block (A: Solution ie remedy for that exception)
  • 20. import java.io.*; //for DataInputStream class class Test { public static void main(String []ar) throws Exception { int age; DataInputStream d = new DataInputStream(System.in); System.out.println("Enter your Age"); age = Integer.parseInt(d.readLine()); //IOException System.out.println("Age:"+ age); } }
  • 21. class Test { public static void main(String []ar) { try { int a=100,b=0,c; c=a/b; } catch (Exception e) //ArithmeticException division by zero { System.out.println(e); } } }
  • 22. • try block must be followed by a single or multiple catch block. • finally block Is executed once whether the exception is raised or not.  House keeping operations like file closing & freeing resources
  • 23. class Test { public static void main(String []ar) { try { int a=100,b=0,c; c=a/b; } catch (Exception e) //ArithmeticException division by zero { System.out.println(e); } finally { System.out.println(“finally block”); } } }
  • 24. •Finalizer  destructor Java  Automatic garbage collected language, System.gc();
  • 25. Inheritance • Deriving a new class from existing class. • Old class or existing class (Super Class) • New class or derived class (Sub Class) Reusability
  • 26. Types of Inheritance 1. Single Inheritance 2. Multiple Inheritance 3. Hierarchical inheritance 4.MultiLevel Inheritance 5.Hybrid inheritance
  • 28. 2.Multiple Inheritance (More than one Super class) Father Son Mother
  • 29. Java doesn’t support Multiple Inheritance. ? But we can do Multiple Inheritance by using interfaces.
  • 30. 3. Hierarchical Inheritance (More than one Sub class) iOSAndroid Mobile OS Blackberry
  • 31. 4. MultiLevel Inheritance (Deriving a Sub cls from existing sub cls) Parent Grand Parent Child
  • 32. 5. Hybrid Inheritance (combination of all types of inheritance)
  • 33. Single Inheritance class A { static int x=10; static int y=20; } class B extends A { public static void main(String[] args) { int z=30; int res=x+y+z; System.out.println("Result:"+res); } }
  • 34. class Shape { int l,b; } class Rectangle extends Shape { int a; public int findArea() { a = l*b; return (a); } public static void main(String args[]) { Rectangle r = new Rectangle(); r.l = 10; r.b = 20; System.out.println("Area of rectangle is:" + r.findArea()); } }
  • 35. Interface Similar to class but contains only declarations of variables and methods. • Methods declared in a interface should be public and abstract (final Vs abstract) • variables declared should be public, static & final
  • 36. Interface Tagging or Markable interface? An interface with no variables & methods eg:- Serializable, Clonnable and Remote interface
  • 37. Interface pgm interface P { void print(); } class A implements P { public void print() { System.out.println("Hello"); } public static void main(String args[]) { A obj = new A(); obj.print(); } }
  • 38. Multiple Inheritance class A { static int x=10; } interface B { static int y=20; } class C extends A implements B { public static void main(String[] args) { System.out.println("Multiplication:"+ x*y); }
  • 39. Multiple Inheritance class A { } class B ________________ A {} interface I1 {} class C ________________ B _________________ I {} Interface I2 _____________ I1 {} x extends y x implements y
  • 40. Constructor & Destructor Constructor  A method which is invoked automatically while creating objects. Constraints: • Constructor name should be same as class name. • No return value for constructor. (even void)
  • 41. Types of Constructor: 1. Default Constructor 2. Parameterized Constructor 3. Copy Constructor 4. Dynamic Constructor
  • 42. Default constructorclass Student { int rno; String name; void display() { System.out.println("Name:"+name); System.out.println("RollNO:"+rno); } public static void main(String args[]) { Student s1=new Student();//default constructor s1.display(); } }
  • 43. 2. Parameterized Constructor class Student { int rno; String name; Student(int r,String s) { rno=r; name=s; } void display() { System.out.println("Name:"+name); System.out.println("RollNO:"+rno); } public static void main(String args[]) { Student s1=new Student(101,"Sudha");//parameterized constructor s1.display(); }
  • 44. Copy Constructor class Student { int rno; String name; Student(int r,String s) { rno=r; name=s; } Student(Student s) // copy constructor { rno=s.rno; name=s.name; }
  • 45. void display() { System.out.println("Name:"+name); System.out.println("RollNO:"+rno); } public static void main(String args[]) { Student s1=new Student(101,"Sudha”); Student s2 = new Student(s1); //Copy Constructor s1.display(); s2.display(); } }
  • 46. Super keyword • super can be used to refer immediate parent class instance variable. • super can be used to invoke immediate parent class method. • super() can be used to invoke immediate parent class constructor.
  • 47. class Fruit { Fruit() { System.out.println("Fruit Class"); } } class Apple extends Fruit { Apple() { super(); System.out.println("Apple class"); } }
  • 48. class Test { public static void main(String args[]) { Apple a=new Apple(); } }
  • 49. this keywordclass A { int a,b; int add(int x, int y) { a=x; b=y; return(a+b); } } class B extends A { public static void main(String args[]) { A a=new A(); System.out.println("Added Value:" + a.add(10,20)); } }
  • 50. class A { int x,y; int add(int x, int y) { this.x=x; this.y=y; return(x+y); } } class B extends A { public static void main(String args[]) { A a=new A(); System.out.println("Added Value:" + a.add(10,20)); } }
  • 51. Method Overloading • Same method name with different signatures. Signature? • Number and type of arguments. int add(int a, int b); int add(int a, int b, int c); double add(int a, double b);
  • 52. //Method Overloading class A { int add(int x, int y) { return(x+y); } int add(int x, int y, int z) { return(x+y+z); } double add(double x, int y) { return(x+y); } }
  • 53. class B extends A { public static void main(String args[]) { A a=new A(); System.out.println("Added Value:" + a.add(10,20)); System.out.println("Added Value:" + a.add(10,20,30)); System.out.println("Added Value:" + a.add(1.2,20)); } }
  • 54. Constructor Overloading • More than one types of constructor used in a single class. • Method Overriding • Same method name with same signature but in 2 different classes namely super class & sub class. Overloading Vs Overriding?
  • 55. // method overriding class A { void show() { System.out.println("I am inside super class"); } } class B extends A { void show() { System.out.println("I am inside sub class"); } }
  • 56. class Test { public static void main(String a[]) { B b = new B(); b.show(); } }
  • 57. Abstract class • A class which can’t be instantiated. Ie we can’t create objects for abstract class. How to create abstract class in Java? 1. Using abstract class. 2. Using at least one abstract method inside a class. 3. An abstract class contains both abstract & non abstract methods.
  • 58. abstract class Bank { abstract int getInterest(); } class SBI extends Bank { int getInterest() { return 7; } }
  • 59. class TestBank { public static void main(String args[]) { Bank b; b=new SBI(); System.out.println("Rate of Interest is: "+b.getInterest()); } }
  • 60. Package • grouping of related classes, Interfaces, methods. • Default Package ? Language import java.lang.*; // no need • Largest Package? awt
  • 61. Java vs javax import java.io.*; vs import javax.rmi.*;
  • 62. • Some Built-in Packages 1) java.lang: defines primitive data types, math operations 2) java.io: supporting input / output operations. 3) java.util: data structures like Linked List, Date / Time operations. 4) java.applet: Contains classes for creating Applets. 5) java.awt: graphical user interfaces 6) java.net: networking operations.
  • 63. Advantages of using packages: • Preventing naming conflicts • Easier maintenance • Controlled access
  • 64. User defined package //create a folder mypack and save Mycls.java in mypack package mypack; public class Mycls { public void getName(String s) { System.out.println(s); } } //compile Mycls.java
  • 65. import mypack.Mycls; public class Test { public static void main(String args[]) { Mycls m = new Mycls(); m.getName("VIIMS"); } } //cd.. //compile Test.java & run // Output:- VIIMS
  • 66. //static keyword import static java.lang.System.*; class Test { public static void main(String b[]) { out.println("Welcome"); } }
  • 67. // Naming conflicts • import java.util.*; • import java.sql.*; Date today ; //ERROR– java.util.Date or java.sql.Date? Solution: java.sql.Date today = new java.sql.Date();
  • 68. APPLETS • Small java programs developed for web applications. console applications Vs Applets 1. main() 1. No main() 2. No browser 2. needs browser or appletviewer
  • 69. Lifecycle of Java Applet java.applet.Applet class • public void init(): is used to initialized the Applet. It is invoked only once. • public void start(): is invoked after the init() method or browser is maximized. It is used to start the Applet. • public void stop(): is used to stop the Applet. It is invoked when Applet is stop or browser is minimized. • public void destroy(): is used to destroy the Applet. It is invoked only once.
  • 70. First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet { public void paint(Graphics g) { g.drawString("welcome",150,150); } }
  • 71. >javac First.java Include <applet> tag in 2 ways 1. In java program itself as comment line and run using appletviewer >appletviewer First.java 2. As a separate .html file and run using any browser.
  • 72. First.java /* <applet code="First.class" width="300" height="300"> </applet> */ import java.applet.Applet; import java.awt.Graphics; public class First extends Applet { public void paint(Graphics g) { g.drawString("welcome",150,150); g.drawLine(20,30,20,300); } }
  • 73. test.html (use any browser) <html> <body> <applet code="First.class" width="300" height="300"> </applet> </body> </html>
  • 74. JDBC (Java Database Connectivity) • Front End • Backend DBMS Vs RDBMS • ODBC vs JDBC
  • 75. SQL 1. DDL i. Create ii. Alter iii. Drop 2. DML i. Select ii. Insert iii. Update iv. Delete 3. DCL i. grant ii. Revoke 4. TCL i. Commit ii. Rollback iii. Save Point
  • 76. Creating a Tableimport java.sql.*; class Test { public static void main(String a[]) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:stucon"); String qs = "create table student(sname text,rno number)"; PreparedStatement ps = con.prepareStatement(qs); ps.executeUpdate(); ps.close(); con.close(); } }
  • 77. Select Queryimport java.sql.*; class Test { public static void main(String a[]) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("Jdbc:Odbc:empcon"); String qs = "select * from EMPLOYEE"; PreparedStatement ps = con.prepareStatement(qs); ResultSet rs = ps.executeQuery(); while(rs.next()) { System.out.println("Employee No :" + rs.getString(1)); System.out.println("Employee Name:" + rs.getString(2)); System.out.println("Salary Rs :" + rs.getString(3)); } ps.close(); con.close(); } }