0% found this document useful (0 votes)
47 views34 pages

Oops With Java Lab Manua Updated

The document is a lab manual for the Object Oriented Programming with Java course at Meerut Institute of Engineering & Technology. It outlines course details, objectives, teaching schemes, lab experiments, and assessment methods. The manual emphasizes the development of programming skills using Java, including concepts like inheritance, polymorphism, and RESTful web services.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views34 pages

Oops With Java Lab Manua Updated

The document is a lab manual for the Object Oriented Programming with Java course at Meerut Institute of Engineering & Technology. It outlines course details, objectives, teaching schemes, lab experiments, and assessment methods. The manual emphasizes the development of programming skills using Java, including concepts like inheritance, polymorphism, and RESTful web services.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Meerut Institute of Engineering & Technology

N.H. 58, Delhi-Roorkee Highway, Baghpat Road Bypass Crossing,


Meerut-250005, UP(India)

LAB MANUAL

Object Oriented Programming with Java


Department of Computer Science & Engineering
Even Semester
Meerut Institute of Engineering and Technology, Meerut

Lab Manual Checklist

Subject Name : OOPs with Java Subject Code : BCS-452

Theory / Lab : Lab

S.
Parameter / Description
No.

1 Basic Course Details

2 Vision and Mission of the Institute, Vision and Mission of the Department, PEOs, POs, PSOs

3 Teaching and Evaluation Scheme, Syllabus of Subject (List of Experiments - as prescribed by AKTU)
Statements of COs, CO-wise Syllabus (List of Experiments), CO-PO Mapping, CO-PSO Mapping,
4
Course End Survey (Blank Form)

5 Lab Performance Plan

6 Attainment Levels and Assessment Tools (direct and indirect methods both)

7 Experiment Setup

8 Lab Manuals

9 Quiz / Viva Questions

10 Students Lists

11 Personal and Class Time-table

Record of CO-Attainment (as per OBE-06B) and Actions taken / to be taken to improve attainment /
12
academic performance

Meerut Institute of Engineering and Technology, Meerut


Department of CSE
Course File # 2023-24
Name of the Course / Subject OOPs with Java

Subject / Course Code BCS452

To be Taught in (Program / Branch


B.Tech
Name)

Semester of Teaching / Course Offering IV

Theory / Lab Lab

Rubrics Based Evaluation (Yes / No) No

Core / Elective Core


Total No. of Lectures / Lab Turns Required
to complete the entire Syllabus 10

Ext.
AKTU Cre Int.
L T P Extra Total Mark
dits Marks
s
Prescribed

Teaching Load 0 50 50
0 2 0 10 1

Faculty Name Mr. Prashant Singh

Designation Assistant Professor

Department CSE

Meerut Institute of Engineering & Technology

Vision
To be an outstanding institution in the country imparting technical education, providing
need-based, value-based and career-based programs and producing self-reliant, self-
sufficient technocrats capable of meeting new challenges.

Mission
The mission of the institute is to educate young aspirants in various technical fields to fulfil
global requirement of human resources by providing sustainable quality education, training
and invigorating environment besides moulding them into skilled competent and socially
responsible citizens who will lead the building of a powerful nation.

Objectives
The objective of the institute is to have necessary instruments and resources to deliver
technical manpower that not only meets the local industry requirements but is also an
acceptable human resource for the global job market in Management & Technology as well
as Master in Computer Application and other technological sectors. We aim to provide
quality technical education facilities to every student admitted to the institute along with the
development of all round personality of the students. To be a technically high and
professional institute, we ensure to provide most competent staff and excellent support
facilities like well-equipped library, lecture theatres, computer and scientific laboratories
fitted with high quality equipment. The institute organizes in-house and outside training
programmes, seminars, conferences and workshops on continuous basis and encourages
participation of staff and students to improve its Academic Pedagogy through innovative
ideas and techniques in order to impart quality education. To fill the perception gap
between expectation of industry and preferences of academia through industry institute cell,
we organize interactive sessions in the campus. To produce competitive professionals for
meeting the upcoming demand of the nation, the institute will always remain dedicated to
the social causes of the public of this region.

State the Vision and Mission of the Department

Vision
“To be an excellent department that imparts value-based quality education,
Research and innovative technology.”

Mission

M1: To fulfill the requirement of skilled human resources with focus on


qualityeducation.
M2: To create globally competent and socially responsible technocrats by providing
value and need based training.
M3: To improve Industry-Institution Interaction and encourage the research
activities.

Program Educational Objectives

After five years of graduation students will:


PEO-1: Students will have the successful careers in the field of computer science
and allied sectors as an innovative engineer.
PEO-2:Students will advance their careers through professional activities,
Certification and higher studies.
PEO-3: Students will be able to exhibits high level of professional skills and
commitment to life-long learning.
PEO-4: Students will be ready to serve society in any manner and become a
responsible and aware citizen.
PEO-5: Establishing students in a leadership role in any field.

Program Specific Outcomes


The Graduates of the Department will attain:
PSO-1: Ability to apply and analyses computational concepts in the areas related
toalgorithms, machine learning, cloud computing, web designing and webservices.
PSO-2: Ability to apply standard practices and methodologies in software
developmentand project management.
PSO-3: Ability to employ fundamental concepts and emerging technologies for
innovative research activities, carrier opportunities & zeal for higher studies.

Program Outcomes
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineeringspecialization to the solution of
complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reachingsubstantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering
problems and design system components orprocesses that meet the specified needs
with appropriate consideration for the public health and safety, and the
cultural,societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design ofexperiments, analysis and interpretation of
data, and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT toolsincluding prediction and modelling to complex
engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legaland cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional
engineering solutions in societal andenvironmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics
andresponsibilities and norms of the engineeringpractice.
9. Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and inmultidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with
the engineering community and withsociety at large, such as, being able to
comprehend and write effective reports and design documentation, make
effectivepresentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of
the engineering and managementprinciples and apply these to one’s own work, as a
member and leader in a team, to manage projects and inmultidisciplinary
environments.
12. Life-long learning:Recognize the need for, and have the preparation and ability to
engage in independent and life-longlearning in the broadest context of technological
change.

University Evaluation Scheme


SEMESTER –IV

Type

Category

End Semester
Sessional (SW)

Examination
Sessional

TS/PS)

(ESE)
Subject Periods Total Credit
SN Subject Component
Code SW+ESE Cr

(
L T P CT TA CT+TA TE/PE
BSC(Maths-III/Math
IV/
BAS403 /
1 Math V)/Science T BS/ES 3 1 0 20 10 30 70 100 4
BOE4**
Based
Open Elective
Technical
Communication /
BAS401 /
2 Universal Human T HS/VA 2 1 0 20 10 30 70 100 3
BVE401
Value and
Professional Ethics
3 BCS401 Operating System T PC 3 1 0 20 10 30 70 100 4
Theory of Automata
4 BCS402 and T PC 3 1 0 20 10 30 70 100 4
Formal Languages
Object Oriented
5 BCS403 Programming with T PC 2 1 0 20 10 30 70 100 3
Java
6 BCS451 Operating System Lab P PC 0 0 2 50 50 50 100 1
Object Oriented
Programming with
7 BCS452 P PC 0 0 2 50 50 50 100 1
Java
Lab
Cyber Security
8 BCS453 P PC 0 0 2 50 50 50 100 1
Workshop
Python
BCC402 /
9 Programming/Cyber P VA 2 0 0 20 10 30 70 100 2
BCC401
Security
BVE451 / Sports and Yoga - II /
10 P VA 0 0 3 100 100 0
BVE452 NSS-II
Total 15 5 9 23
Minor Degree/ Honors
Degree MT-1/HT-1
*The Mini Project or internship (4 weeks) will be done during summer break after 4th Semester and will be
assessed during V semester.

OOPs with Java Lab


SYLLABUS
1. Use Java compiler and eclipse platform to write and execute java program.

2. Creating simple java programs using command line arguments

3. Understand OOP concepts and basics of Java programming.

4. Create Java programs using inheritance and polymorphism.

5. Implement error-handling techniques using exception handling and multithreading.

6. Create java program with the use of java packages.

7. Construct java program using Java I/O package.

8. Create industry oriented application using Spring Framework

9. Test RESTful web services using Spring Boot.

10.Test Frontend web application with Spring Boot

Course Outcomes
CO-1 Develop the object-oriented programming concepts using Java
CO-2 Implement exception handling, file handling, and multi-threading in Java
CO-3 Test web and RESTful Web Services with Spring Boot using Spring Framework concepts

List of Experiments
(CO-Wise Syllabus)

1. Use Java compiler and eclipse platform to write and execute java program. CO1

2. Creating simple java programs using command line arguments. CO1

3. Understand OOP concepts and basics of Java programming. CO2

4. Create Java programs using inheritance and polymorphism. CO2

5. Implement error-handling techniques using exception handling and multithreading. CO3

6. Create java program with the use of java packages. CO4

7. Construct java program using Java I/O package. CO4

8. Create industry oriented application using Spring Framework CO5

9. Test RESTful web services using Spring Boot. CO5

10.Test Frontend web application with Spring Boot CO5

CO-PO-PSO Mapping
CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3

CO1 3 3 2 2 2 2 2 2 2

CO2 3 3 3 2 2 3 1 1 2
CO3 3 2 3 2 2 3 2 1 2
CO4 3 3 3 3 2 3 1 1 1

CO5 3 3 3 2 2 3 2 1 2

Meerut Institute of Engineering and Technology, Meerut


Course End Survey # 2023-24 ( Even Sem)
Name of the
B.Tech Session : 2023-24
Course :
Course Code : BCS452 Semester : IV
Name of the
Mr. Vijay Kumar Sharma Student Roll No (Optional) :
Faculty :
Department : CSE Student Name (Optional) :
Tick in appropriate column
Partially
S. No. Statement Agree Disagree
Agree
I am able todevelop the object-oriented programming
1
concepts using Java

I am able toImplement exception handling, file handling,


2
and multi-threading in Java
I am able todevelop RESTful Web Services with Spring
3 Boot using Spring Framework concepts.

Lab Performance Plan

S.No. Experiment CO Date


1 Use Java compiler and eclipse platform to write and 1
execute java program
Creating simple java programs using command line
2 1
arguments
3 Understand OOP concepts and basics of Java programming 1
4. Create Java programs using inheritance and polymorphism 1
Implement error-handling techniques using exception
5. 2
handling and multithreading
6. Create java program with the use of java packages 2
7. Construct java program using Java I/O package 2
Create industry oriented application using Spring
8. 3
Framework
9. Test RESTful web services using Spring Boot 3
10. Test Frontend web application with Spring Boot. 3

Department of Computer Science & Engineering

Attainment Level and Assessment Tools / Methods


1. ATTAINMENT LEVELS

1a. Attainment Levels: Theory Course


Assessment Methods Level Range of Students in a class / branch with target marks
1 <50% student secure 60% marks
Direct Assessment
2 >=50 <60% student secure 60% marks
(Internal Evaluation)
3 >=60% student secure 60% marks
1 <50% student secure 50% marks
Direct Assessment
2 >=50 <60% student secure 50% marks
(External Evaluation)
3 >=60% student secure 50% marks
Indirect Assessment To be conducted at 3-point scale and weighted method is to be
(Course End Survey) considered for Attainment Value of Indirect Assessment

1b. Attainment Levels: Lab Course


Assessment Methods Level Range of Students in a class / branch with target marks
1 <50% student secure 70% marks
Direct Assessment
2 >=50 <60% student secure 70% marks
(Internal Evaluation)
3 >=60% student secure 70% marks
1 <50% student secure 70% marks
Direct Assessment
2 >=50 <60% student secure 70% marks
(External Evaluation)
3 >=60% student secure 70% marks
Indirect Assessment To be conducted at 3 point scale and weighted method is to be
(Course End Survey) considered for Attainment Value of Indirect Assessment

2. ASSESSMENT TOOL

2a. Assessment Tool: Theory Course


Subject Assessment Frequency per
Assessment Method Assessment Tool
Type components Semester
Sessional-I; One
Internal Assessment Sessional-II ; One
(30% ) weightage PUTs One
Direct Assessment
Assignment / Quiz One for each CO
Theory (80% weightage)
(all COs) External Assessment
University Examination Once
(70% weightage)

Indirect Assessment
- Course End Survey Once
(20% weightage)

2b. Assessment Tool: Lab Course


Subject ● Assessment Frequency per
Assessment Method Assessment Tool
Type components Semester
Lab Direct Assessment Internal Assessment Quiz / Viva and At the end of course /
(all COs) (80% weightage) (30% weightage) Continuous Evaluation After every experiment
External Assessment
University Examination Once
(70% weightage)
Indirect Assessment
- Course End Survey Once
(20% weightage)

3. ASSESSMENT METHODS AND WEIGHTAGE

3a. Assessment Methods


To compute attainment value of COs, there are two type of assessment methods:
a. Direct Assessment b. Indirect Assessment
Further, Direct Assessment includes
a. Internal assessment (to be done at college level)
b. External assessment (to be done at university level)
Assessment Components for Direct Assessment (Internal)
Written Tests (Sessional Tests / Class Tests), Pre University Tests
Home-assignments, Quizzes
Presentations, Viva, Models, Projects, Development of Teaching Aids
Research Article Review, Case Study, Open Problem
Continuous Assessment of Lab Work
Group of any few can be defined / considered for CO-attainment (group of assessment methods
may vary from one CO to another within the same course and similarly, for other courses)
Assessment Component for Direct Assessment (External)
End Semester Exams
Assessment Component for Indirect Assessment
Course End Survey / Teacher’s Feedback about the course

3b. Weightage of Assessment Methods


The weightage of Direct and Indirect method is 80:20 percent.
The weightage of Direct (Internal) and Direct (External) will be as per AKTU’s Marks Scheme. The
marks distribution of a subject as per AKTU’s Teaching and Evaluation Scheme is as (any one) :
Total Marks of Subject = 150 (Internal Marks = 50; External Marks = 100)
Total Marks of Subject = 100 (Internal Marks = 30; External Marks = 70)
Considering higher side of external assessment; the weightage of Direct (Internal) and Direct
(External) will be 30% and 70% respective. The same will be adopted for Lab.

Experiment Setup
● Operating System (UNIX, LINUX, WINDOWSXP, WINDOWS7/8/10)
● 4gb Ram
● JDK & JRE

Experiment No.1
Aim:-Use Java compiler and eclipse platform to write and execute java program.

Program:-
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
Experiment No.2
Aim:-Creating simple java programs using command line arguments.

Program:-
public class CommandLineArguments {
public static void main(String[] args) {
// Check if any command line arguments are provided
if (args.length == 0) {
System.out.println("No command line arguments provided.");
} else {
System.out.println("Command line arguments:");
// Print each command line argument
for (inti = 0; i<args.length; i++) {
System.out.println("Argument " + (i + 1) + ": " + args[i]);
}
}
}
}
Experiment No.3
Aim:-Understand OOP concepts and basics of Java programming.

Program:-
Class:
public class Car {
// Fields
String make;
String model;
int year;

// Constructor
public Car(String make, String model, int year) {
this.make = make;
this.model = model;
this.year = year;
}

// Method
public void start() {
System.out.println("The " + make + " " + model + " is starting.");
}
}
Object:
Car myCar = new Car("Toyota", "Corolla", 2022);
Inheritance:
public class ElectricCar extends Car {
// Additional fields and methods specific to ElectricCar
public ElectricCar(String make, String model, int year) {
super(make, model, year);
}
}
Polymorphism:
public interface Vehicle {
void start();
}

public class Car implements Vehicle {


// Implementation of start() method
}

public class Motorcycle implements Vehicle {


// Implementation of start() method
}
Abstraction:
public interface Shape {
double calculateArea();
}

public class Circle implements Shape {


// Implementation of calculateArea() method
}

public class Rectangle implements Shape {


// Implementation of calculateArea() method
}
Experiment No.4
Aim: - Create Java programs using inheritance and polymorphism.

Program:-
// Parent class
class Animal {
public void makeSound() {
System.out.println("Animal makes a sound");
}
}

// Child class 1 inheriting from Animal


class Dog extends Animal {
@Override
public void makeSound() {
System.out.println("Dog barks");
}
}

// Child class 2 inheriting from Animal


class Cat extends Animal {
@Override
public void makeSound() {
System.out.println("Cat meows");
}
}

// Polymorphic method that accepts Animal objects


class AnimalSound {
public void animalMakesSound(Animal animal) {
animal.makeSound();
}
}

public class Main {


public static void main(String[] args) {
AnimalSoundanimalSound = new AnimalSound();

// Create objects of different subclasses


Animal animal1 = new Animal();
Animal animal2 = new Dog();
Animal animal3 = new Cat();

// Call the polymorphic method with different objects


animalSound.animalMakesSound(animal1);
animalSound.animalMakesSound(animal2);
animalSound.animalMakesSound(animal3);
}
}
Experiment No.5
Aim: - Implement error-handling techniques using exception handling and multithreading.

Program:-
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

// Custom exception class


class MyCustomException extends Exception {
public MyCustomException(String message) {
super(message);
}
}

// Runnable task that may throw an exception


class MyTask implements Runnable {
@Override
public void run() {
try {
// Simulating some operation that may throw an exception
if (Math.random() < 0.5) {
throw new MyCustomException("Exception occurred in task");
}
// Simulating a long-running task
Thread.sleep(1000);
System.out.println("Task completed successfully");
} catch (InterruptedException e) {
System.out.println("Task interrupted");
} catch (MyCustomException e) {
System.out.println("Custom Exception: " + e.getMessage());
}
}
}

public class Main {


public static void main(String[] args) {
// Create a fixed-size thread pool
ExecutorService executor = Executors.newFixedThreadPool(3);

// Submit tasks to the thread pool


for (inti = 0; i< 5; i++) {
executor.submit(new MyTask());
}

// Shutdown the executor once all tasks are completed


executor.shutdown();
}
}
Experiment No.6
Aim: - Create java program with the use of java packages.

Program:-
javac command:
# javac shapes/Circle.java
#javac main/Main.java
java command:
#java main.Main

// Define a package named 'shapes'


package shapes;

// Class representing a circle


public class Circle {
private double radius;

// Constructor
public Circle(double radius) {
this.radius = radius;
}

// Method to calculate area of the circle


public double calculateArea() {
return Math.PI * radius * radius;
}
}

// Define another package named 'main'


package main;
// Import the Circle class from the 'shapes' package
import shapes.Circle;

public class Main {


public static void main(String[] args) {
// Create an instance of Circle
Circle circle = new Circle(5);

// Calculate and print the area of the circle


System.out.println("Area of the circle: " + circle.calculateArea());
}
}
Experiment No.7
Aim: - Construct java program using Java I/O package.

Program:-
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Main {


public static void main(String[] args) {
String inputFile = "input.txt";
String outputFile = "output.txt";

// Write data to a file


try (BufferedWriter writer = new BufferedWriter(new FileWriter(inputFile))) {
writer.write("Hello, World!\n");
writer.write("This is a Java I/O example.\n");
writer.write("Using BufferedReader and BufferedWriter.\n");
writer.write("Reading from input.txt and writing to output.txt.");
} catch (IOException e) {
System.err.println("Error writing to file: " + e.getMessage());
}

// Read data from the file and display it


try (BufferedReader reader = new BufferedReader(new FileReader(inputFile))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
System.err.println("Error reading from file: " + e.getMessage());
}

System.out.println("Data has been read from " + inputFile + " and written to " + outputFile);
}
}
Experiment No.8
Aim: -Create industry oriented application using Spring Framework.

Program:-
// Product entity class
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private double price;
// constructors, getters, setters
}

// Product repository interface


public interface ProductRepository extends JpaRepository<Product, Long> {
}

// Product service class


@Service
public class ProductService {
@Autowired
private ProductRepositoryproductRepository;

public List<Product>getAllProducts() {
return productRepository.findAll();
}

public Product getProductById(Long id) {


return productRepository.findById(id).orElse(null);
}

public Product saveProduct(Product product) {


return productRepository.save(product);
}

public void deleteProduct(Long id) {


productRepository.deleteById(id);
}
}

// Product controller class


@RestController
@RequestMapping("/products")
public class ProductController {
@Autowired
private ProductServiceproductService;

@GetMapping
public List<Product>getAllProducts() {
return productService.getAllProducts();
}

@GetMapping("/{id}")
public Product getProductById(@PathVariable Long id) {
return productService.getProductById(id);
}

@PostMapping
public Product addProduct(@RequestBody Product product) {
return productService.saveProduct(product);
}
@DeleteMapping("/{id}")
public void deleteProduct(@PathVariable Long id) {
productService.deleteProduct(id);
}
}

// Spring Boot application class


@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Experiment No.9
Aim: -Test RESTful web services using Spring Boot.

Program:-
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ProductControllerIntegrationTest {
@Autowired
private TestRestTemplaterestTemplate;

@LocalServerPort
private int port;

@Test
public void testGetAllProducts() {
ResponseEntity<String> response = restTemplate.getForEntity(
"http://localhost:" + port + "/products", String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
// Add more assertions as needed
}

// Write more test cases for other endpoints


}
Experiment No.10
Aim: -Test Frontend web application with Spring Boot.

Program:-
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class FrontendTest {


@Test
public void testLoginPage() {
// Set ChromeDriver path
System.setProperty("webdriver.chrome.driver", "path_to_chromedriver");

// Initialize ChromeDriver
WebDriver driver = new ChromeDriver();

// Open the login page


driver.get("http://localhost:8080/login");

// Perform actions (e.g., fill in the form, click buttons)

// Assert expected results


// For example, verify that the login page elements are displayed correctly
// Close the browser
driver.quit();
}
}

You might also like