DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
UNIVERSITY INSTITUTE OF ENGINEERING
Subject Name –OBJECT ORIENTED PROGRAMMING USING JAVA
Subject Code – 24ITH-207
Submitted To: Submitted By:
Faculty Name: Dr. Anshu Mehta Name: Aditya Gupta
UID: 24BET10066
Section: 719-B
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Department of ComputerScience & Engineering
INDEX
Viva
Exp. List of Experiments Conduct (M.M:5) Record Total Remarks
No (M.M:20) (M.M:5) (M.M:30)
1. Java String
Operations and
Class
Implementation
2.
3.
4.
5.
6.
7.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Worksheet 1
Student Name:Samarth K hare UID: 24BCS10404
Branch: BE-CSE Section/Group: 719/B
Semester:3rd Date of Performance:20/01/2026
Subject Name:ObjectOriented Subject Code:24CSH-207
Programming UsingJava
1. Aim:
Question 1:
Youaregiven a string S. Using Java String class methods only, perform the
following operations: Print the length of the string Convert the string to
uppercase Convert the string to lowercase Print the first character of the
string Print the last character of the string Each output should be printed on a
new line.
Input Format
A single line containing a string S
Constraints
1 ≤ length of S ≤ 1000 String may contain alphabets, digits, and spaces
Output Format
Print the following in order: Length of the string Uppercase version of the
string Lowercase version of the string First character Last character Each on
a new line.
Question 2:
Create a class named Car with the following data members:
String brand
String model
Integer year
Create an object of the class, assign values to the variables, and display the
car details using a method showDetails().
Input Format
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Three lines of input:
Brand name
Model name
Manufacturing year
Constraints
Brand and model contain only alphabets
1900 ≤ year ≤ 2100
Output Format
Print the car details as: Brand: Model: Year:
2. Requirements (Hardware/Software):
Hackerrank
3. Procedure:
Code 1:
[Link];
publicclass main()
{
publicstatic void main(String[] args) {
Scanner sc = new Scanner([Link]);
String s = [Link]();
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link](0));
[Link]([Link]([Link]() - 1));
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Inputs:
Hello
Code 2:
import [Link];
class Car {
String brand, model;
int year;
void showDetails() {
[Link]("Brand: " + brand);
[Link]("Modell: " + model);
[Link]("Year: " + year);
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
Car c = new Car();
[Link] = [Link]();
[Link] = [Link]();
[Link] = [Link]();
[Link]();
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Inputs:
pro
second
2
4. Output:
Code 1:
5
HELLO
hello
H
o
Code 2:
Brand: pro
Modell: second
Year: 23
5. Learningoutcomes:
● Learned how to take user input using the Scanner class in Java.
● Understood and used different String class methods such as length(),
toUpperCase(), toLowerCase(), and charAt().
● Gained knowledge about accessing characters from a string.
● Learned how to create a class and object in Java.
● Understood how to assign values to data members of a class.
● I learned how to define and call methods in Java.
● Improved understanding of object-oriented programming concepts like
encapsulation and method usage.