0% found this document useful (0 votes)
7 views

Lab#01

The document outlines Lab 01 for the CS 212: Object Oriented Programming course, focusing on basic programming in Java. Students will learn to create a 'Hello World' program and complete various tasks involving pattern printing using Java. The lab requires the installation of an IDE and includes instructions for compiling and running Java programs.

Uploaded by

XdCatalyst Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lab#01

The document outlines Lab 01 for the CS 212: Object Oriented Programming course, focusing on basic programming in Java. Students will learn to create a 'Hello World' program and complete various tasks involving pattern printing using Java. The lab requires the installation of an IDE and includes instructions for compiling and running Java programs.

Uploaded by

XdCatalyst Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Department of Computing

CS 212: Object Oriented Programming


Class: BSAI-1
Lab 01: Basic Programming in Java

Date: 28thJan2025
Time: 9:00am- 12:00pm

CS 212: Object Oriented Programming Page 1


Lab 1: Basic Programming in Java
Introduction
After completing this lab students will be able to do some printing task in Java.

Objectives
Your first activity will be creating the "Hello World" program using Java.

Tools/Software Requirement
NetBeans. Eclipse, VS Code,IntelliJ IDEA

Description
What is Java?

Java is a popular, high-level, object-oriented programming language developed by Sun


Microsystems (now owned by Oracle). It is designed to be platform-independent, meaning that
Java programs can run on any system that has a Java Virtual Machine (JVM) installed, regardless
of the operating system. This is based on the principle of "Write Once, Run Anywhere" (WORA).

Why Java:

Java is widely used due to its platform independence, as programs can run on any machine with
the Java Virtual Machine (JVM) installed. It is an object-oriented language, promoting reusable,
maintainable, and modular code. Java also offers robust security features like sandboxing and
bytecode verification, making it safe for distributed applications. Its rich API covers everything
from networking to UI components, helping developers create powerful applications. With
multithreading support, Java enables efficient, responsive programs, while Just-In-Time (JIT)
compilation enhances performance. The large Java community and its cross-platform capabilities
further contribute to its popularity and effectiveness in software development.

JVM

JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn't
physically exist. It is a specification that provides a runtime environment in which Java bytecode
can be executed. It can also run those programs which are written in other languages and compiled
to Java bytecode.

JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform
dependent because the configuration of each OS is different from each other. However, Java is
platform independent. There are three notions of the JVM: specification, implementation,
and instance.

JRE

CS 212: Object Oriented Programming Page 2


JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java
Runtime Environment is a set of software tools which are used for developing Java applications.
It is used to provide the runtime environment. It is the implementation of JVM. It physically exists.
It contains a set of libraries + other files that JVM uses at runtime.

JDK

JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software
development environment which is used to develop Java applications and applets. It physically
exists. It contains JRE + development tools.

Task 1: Install an IDE of your choice

For this task, you can choose from the following popular Integrated Development Environments
(IDEs):

1. NetBeans

CS 212: Object Oriented Programming Page 3


2. Eclipse
3. VS Code
4. IntelliJ IDEA

Steps to install “IntelliJ IDEA”


https://www.youtube.com/watch?v=ntLJmHOJ0ME&list=PLu0W_9lII9agS67Uits0UnJyrYiXh
DS6q

Screenshots of Steps:

CS 212: Object Oriented Programming Page 4


Activity #1.
(NOTE: Execute the program by using cmd prompt and IDE both).
Your first task will be creating the "Hello World" program using java. Create a new directory
CS-212, and navigate into it. Using notepad or the editor of your choice (preferably NetBeans),
create a file called ActivityOne.java and enter the following code:

// This program outputs the message "Hello World"


public class ActivityOne
{
public static void main (String args [])
{
System.out.println ("Hello World");
}
}

Save the file, and open command window to use for compiling and running your program. In the
new window, navigate into your CS-212 directory and issue the following command to compile
the program

Demo:
https://www.youtube.com/watch?v=uA4eQbC3JgA

Error Handling:

https://www.youtube.com/watch?v=lITsZKidY1s&list=PL8p2I9Gkl
V466xs0qGUvLGAXy6xLyEcQy&index=3

OUTPUT:

CS 212: Object Oriented Programming Page 5


Sample:

Try it….

Task 1: Write a Java program to print the following pattern:

 Print a Heart Shape

CS 212: Object Oriented Programming Page 6


Task 2: Write a Java program to print the following pattern:

 Print a Smiley Face

Task 3: Write a Java program to print the following pattern:

 Print a Diamond Shape

Task 4: Write a Java program to print the following pattern:

 Print a Rocket Ship

CS 212: Object Oriented Programming Page 7


Task 5: Write a Java program to print the following pattern:

 Print a Butterfly

Task 6: Write a Java program to print the following pattern:

 Print a Fish:

Task 7: Write a Java program to print the following pattern:

 Print a Sun:

CS 212: Object Oriented Programming Page 8


Task 8: Write a Java program to print the following pattern:

 Print a Cat:

Deliverables:

Submit the Docx file on LMS.

CS 212: Object Oriented Programming Page 9

You might also like