Object Oriebted LAB (Manual)
Object Oriebted LAB (Manual)
Name _____________________
Roll No ____________________
Semester ____________________
Marks ____________________
Signature ____________________
The first step in OOP is to identify all the objects the programmer wants to manipulate and how
they relate to each other, known as data modeling. Once an object has been identified, it is
generalized as a class of objects which defines the kind of data it contains and any logic
sequences that can manipulate it.
1. Abstraction
2. Encapsulation.
3. Inheritance.
4. Polymorphism.
Java
Java is a programming language and a platform based on object-oriented programming concepts.
It was first released by Sun Microsystems in 1995.
There are lots of applications and websites that will not work unless Java is being installed, and
more are created every day. Java is high level, fast, secure, and reliable.
From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the
Internet, Java is everywhere!
Lab
Lab Objective
No.
1 Introduction to Java
2 Java Programming Elements
3 Java Control Statement , Operators & Arrays
4 Introducing Classes ,Objects and Strings in java
5 Overloading and Access Control
6 Introducing UML Diagram
7 Inheritance and Polymorphism in Java
8 Use of abstract and final
9 Packages & Interfaces
10 Introducing JavaFx – Java GUI
11 Exploring JavaFx
12 JavaFx Application
13 Exception Handling
14 Generics and Collection
15 Serialization
Lab Details
Marks
Lab No. Lab Objective Signature
Obtained
Introduction to Java
1 Objective: Getting familiar with the Java development kit (JDK).
Running your first Java program using CMD and an IDE.
Student Feedback:
Student Feedback:
Student Feedback:
Student Feedback:
12 JavaFx Application
Objective: Design a Login page using JavaFx components
Student Feedback:
Exception Handling
13
Objective: Understand how runtime errors are being handled in Java.
Student Feedback:
Serilization
Objective: File Processing & I/O operations, ObjectInputStream,
15
ObjectOutputStream, Serializable interface, Serializing & Deserializing an
Object
Student Feedback:
Note: Students are advised to write their comments about whether the objective of the lab was achieved in
Student Feedback.
Introduction to Java Lab 1
Objective: Getting familiar with the Java development kit (JDK). Running your first Java program using
CMD and an IDE.
Theory:
What is JDK?
It's the full featured Software Development Kit for Java, including JRE, and the compilers and tools (like Java
Debugger) to create and compile programs.
JRE is required to run Java programs while JDK is required when you have to do some Java programming.
2. Run the .exe file on your System and follow the steps as given by the installer.
Figure 1.2 Installing JDK
3. Note down the location where j2se has been installed. Java Platform is also called as J2SE (Java 2
Platform Standard Edition)
To set the temporary path of JDK, you need to follow following steps:
For setting the permanent path of JDK, you need to follow these steps:
Go to
MyComputer properties -> advanced tab -> environment variables -> new tab of user variable ->
write path in variable name -> write path of bin folder in variable value -> ok -> ok -> ok
Copy the path of the bin folder of the JDK and paste it in the variable value field of the path
variable. So add ";C:\Program Files\Java\jdk1.7.0_02\bin" in the path string.
Note:
The PATH environment variable is a series of directories separated by semicolons (;) and is notcase-
sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.
The new path takes effect in each new command window you open after setting the PATH variable.
Lab Task:
public static void main(String args[]){
System.out.println(“Hello World!!”);
}
}
2. Save it as HelloWorld.java. Naming is strictly case-sensitive; make sure you type as it is given above.
3. Now open a command prompt and change to the directory where you have saved HelloWorld.java
4. Enter SET CLASSPATH.
5. Press enter; this sets the classloader path to search for class files in the current directory.
6. Type the command javac to compile your code. If the compilation is successful, you would not be
shown any errors.
javac HelloWorld.java
Type the command java HelloWorld and press enter. Please note that you did not include any
extension such as .java or .class to the class name you wish to run.
javaHelloWorld
7. You would get nice output greeting “Hello World!!”
What is an IDE?
There are different IDE’s used for Java development including NetBeans and Eclipse.
Before starting to develop the complex programs, you need an IDE. In this workbook we will be using
Eclipse IDE for code writing, compilation and execution.
After installation, open eclipse. You will see the welcome screen.
Create new project in eclipse. Click on file menu, select Project, then select Java Project and click
Next. You will see the following screen. Give your project a name and click Finish.
Figure 1.11: Creating new project in Eclipse
Now right click on your project available in project explorer and create new class.
Figure 1.12: Add new Class
A window similar to one shown below will appear. Enter the class name and check the checkbox for
public static void main (String[] args). Click finish.
A java file will open with some added code. Just add the following line inside the main()
method.System.out.println("Hello World!!");
Figure 1.14: Adding Java Code
The output of this code will be generated in the console window present below.
Figure 1.16: Console Output
Lab Assignment:
1. Write a simple java program with command-line argument in java that prints your bio data
including:
name, father name, roll number i.d, department, subject, date, zodiac.
public static void main(String args[]){
System.out.println(“My name is Miss Javeria, Barkat,3456, computer science,
oop lab, 14th july, caprocorn”);
}
}