0% found this document useful (0 votes)
3 views8 pages

Java Programming Lab Manual (Cs406)

The lab manual for CS406(a) at Vidhapeeth Institute of Science and Technology introduces Java programming concepts such as classes, inheritance, and multithreading. It includes a list of experiments that cover installation, variable scope, exception handling, and database connectivity, among others. The manual aims to provide practical understanding and implementation of Java programming for students.

Uploaded by

vistcseit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views8 pages

Java Programming Lab Manual (Cs406)

The lab manual for CS406(a) at Vidhapeeth Institute of Science and Technology introduces Java programming concepts such as classes, inheritance, and multithreading. It includes a list of experiments that cover installation, variable scope, exception handling, and database connectivity, among others. The manual aims to provide practical understanding and implementation of Java programming for students.

Uploaded by

vistcseit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

VIDHAPEETH INSTITUTE OF SCIENCE AND

TECHNOLOGY ,Bhopal(MP)
Computer Science and Engineering (IV Semester)
CS406(a): Programming Practices (Java) - Lab Manual
NAME OF FACULTY : NITESH KUMAR DUBEY

OBJECTIVE
To introduce students to Java programming concepts including classes,
objects, inheritance, exception handling, multithreading, and database
connectivity. Students will learn to create, debug, and execute Java
programs using the Java SDK.

LAB REQUIREMENTS
 System with JDK installed
 IDE (NetBeans / Eclipse / IntelliJ/VS CODE) or Command Prompt
 Apache Tomcat Server
 MySQL Database

EXPERIMENT LIST
1. Installation of J2SDK
2. Scope of Variables
3. Concept of Class
4. Type Casting
5. Exception Handling
6. Inheritance
7. Polymorphism
8. Access Specifiers
9. Constructors
10. Interface Implementation
11. Package Creation
12. Thread Life Cycle
13. AWT Demonstration(Outdated still in syllabus)
14. Hidden Class Concept
15. Database Connectivity
16. Applet Program(not working still in syllabus)
17. JDBC Connectivity
18. Multithreading
19. Applet Life Cycle(not working still in syllabus)
20. Servlet Demonstration(Outdated still in syllabus)

Note: Aims have to be same students/faculty can use


different experiments and showing output is mandatory.
EXPERIMENT 1: INSTALLATION OF J2SDK
Aim: To install Java Development Kit.
Procedure:
1. Download JDK from Oracle website.
2. Install JDK.
3. Set environment variables (JAVA_HOME, PATH).
4. Verify installation using java -version.

EXPERIMENT 2: SCOPE OF VARIABLES


Aim: To demonstrate scope of variables.
class ScopeDemo {
int x = 10;
void display() {
int y = 20;
[Link]("Local: " + y);
}
public static void main(String args[]) {
ScopeDemo obj = new ScopeDemo();
[Link]("Global: " + obj.x);
[Link]();
}
}

EXPERIMENT 3: CLASS CONCEPT


Aim: To demonstrate class and object.
class Student {
int id;
String name;
void display() {
[Link](id + " " + name);
}
public static void main(String args[]) {
Student s = new Student();
[Link] = 1;
[Link] = "John";
[Link]();
}
}

EXPERIMENT 4: TYPE CASTING


Aim: To demonstrate type casting.
class TypeCasting {
public static void main(String args[]) {
double d = 10.5;
int i = (int)d;
[Link](i);
}
}

EXPERIMENT 5: EXCEPTION HANDLING


Aim: To demonstrate exception handling.
class ExceptionDemo {
public static void main(String args[]) {
try {
int a = 10/0;
} catch(Exception e) {
[Link]("Exception Caught");
}
}
}

EXPERIMENT 6: INHERITANCE
class A {
void show() { [Link]("Class A"); }
}
class B extends A {
void display() { [Link]("Class B"); }
}
class Test {
public static void main(String args[]) {
B obj = new B();
[Link]();
[Link]();
}
}

EXPERIMENT 7: POLYMORPHISM
class Poly {
void add(int a, int b) {
[Link](a+b);
}
void add(double a, double b) {
[Link](a+b);
}
}
class Test {
public static void main(String args[]) {
Poly p = new Poly();
[Link](2,3);
[Link](2.5,3.5);
}
}

EXPERIMENT 8: ACCESS SPECIFIERS


class Demo {
public int a = 10;
private int b = 20;
protected int c = 30;
}

EXPERIMENT 9: CONSTRUCTORS
class Cons {
Cons() {
[Link]("Constructor Called");
}
public static void main(String args[]) {
Cons c = new Cons();
}
}
EXPERIMENT 10: INTERFACE
interface A {
void show();
}
class B implements A {
public void show() {
[Link]("Interface Implemented");
}
public static void main(String args[]) {
B obj = new B();
[Link]();
}
}

EXPERIMENT 11: PACKAGE


package mypack;
class Demo {
public void show() {
[Link]("Package Created");
}
}

EXPERIMENT 12: THREAD LIFE CYCLE


class ThreadDemo extends Thread {
public void run() {
[Link]("Thread Running");
}
public static void main(String args[]) {
ThreadDemo t = new ThreadDemo();
[Link]();
}
}

EXPERIMENT 13: AWT


import [Link].*;
class AWTExample extends Frame {
AWTExample() {
Button b = new Button("Click");
[Link](50,50,80,30);
add(b);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public static void main(String args[]) {
new AWTExample();
}
}

EXPERIMENT 14: HIDE CLASS


class Outer {
private class Inner {
void msg() { [Link]("Hidden Class"); }
}
}

EXPERIMENT 15: DATABASE CONNECTIVITY


import [Link].*;
class DBConn {
public static void main(String args[]) throws Exception {
Connection con =
[Link]("jdbc:mysql://localhost:3306/test","root",
"");
[Link]("Connected");
}
}

EXPERIMENT 16: APPLET


import [Link].*;
import [Link].*;
public class HelloApplet extends Applet {
public void paint(Graphics g) {
[Link]("Hello Java", 50, 50);
}
}

EXPERIMENT 17: JDBC


import [Link].*;
class JDBCExample {
public static void main(String args[]) throws Exception {
Connection con =
[Link]("jdbc:mysql://localhost:3306/test","root",
"");
Statement st = [Link]();
ResultSet rs = [Link]("select * from student");
while([Link]()) {
[Link]([Link](1));
}
}
}

EXPERIMENT 18: MULTITHREADING


class Multi extends Thread {
public void run() {
[Link]("Thread Execution");
}
public static void main(String args[]) {
Multi m = new Multi();
[Link]();
}
}

EXPERIMENT 19: APPLET LIFE CYCLE


import [Link].*;
public class LifeCycle extends Applet {
public void init() {}
public void start() {}
public void stop() {}
public void destroy() {}
}

EXPERIMENT 20: SERVLET


import [Link].*;
import [Link].*;
import [Link].*;
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
[Link]().println("Hello Servlet");
}
}
VIVA QUESTIONS
1. What is JVM?
2. Difference between JDK and JRE?
3. What is inheritance?
4. Explain polymorphism.
5. What is multithreading?

CONCLUSION
This lab manual helps students understand and implement Java
programming concepts practically.

You might also like