Oop Lab Manula

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

Lab manual of oop

Lab: 01

Step-I: First Download JDK on given below website

Step-II: Show Download Process below


Executing /running JDK on systems

Step-III:
Download JRE on given below website
Step-IV:
Show Download Process of JRE
Step-V:
Executing JRE on system
Show installing Process
Java:
Java is a general-purpose computer-programming language that is concurrent, class-
based, object-oriented, and specifically designed to have as few implementation
dependencies as possible.
Designed by

James Gosling
platform

Microsoft Windows
Latest reseal

Java 10 (March 20, 2018)


Influenced by

Ada, Bea HYPERLINK "https://www.google.com/search?client=firefox-b-


ab&q=BeanShell&stick=H4sIAAAAAAAAAOPgE-
LSz9U3MC9Oyk5LUuIEsU2Tyo2StPQzyq30k_NzclKTSzLz8_QLivLTixJzczPz0uNzEvP
SSxPTU4utMvPSckpT85JTUxaxcjqlJuYFZ6Tm5AAAxTjzaFYAAAA&sa=X&ved=2ahUK
EwiD3dSF7rrgAhWSzaQKHQhdDpIQmxMoAjAnegQIAxAT"nShell, C#, Chapel, Clojure,
ECMAScript,

Ada, C++, C#, Eiffel, Mesa, Modula-3, Oberon, Objective-C, UCSD Pascal, Object
Pascal

JDK
JDK. (Java Development Kit) A Java software development environment from Oracle. It
includes the JVM, compiler, debugger and other tools for developing Java applets and
applications.

Use of jdkThe APIs described here are those that are provided with the Oracle JDK. It
includes a complete implementation of the Java SE 11 Platform and additional Java APIs to
support developing, debugging, and monitoring Java applications.
Jvm
A JVM is a software-based machine that runs Java programs. ... However, the Java code from a
.JAVA file must first be converted into instructions the JVM can understand. This binary format,
called "bytecode," can be processed one instruction at a time or compiled into a .CLASS file
before execution to improve performance.

Uses of jvm
A Java Virtual Machine, or JVM, is a software virtual machine that runs compiled Java
code. Because compiled Java code is merely bytecode, the JVM is responsible for
compiling that bytecode to machine code before running it. (This is often called the Just
in Time Compiler or JIT Compiler.)

TASK #01
CODE:
class Hello{

public static void main(String[] args){

System.out.println("Hello World");

Compile and Run:

LAB :02
TASK #01
CODE:
class Calculator{

void add(int a,int b){

System.out.println(a+b);

public static void main(String[] args){

Calculator obj=new Calculator();

obj.add(15,16);

Compile and Run:

TASK #02
CODE:
class Calculator{

void add1(int x,int y){

System.out.println(x+y);

return x+y;

public static void main(String[] args){

Calculator obj=new Calculator();

obj.add1(15,16);

}
Compile and Run:

TASK #03
CODE:
class Test{

public static void main(String[] args){

int i;

for(i=0;i<10;i++)

System.out.println(i);

TASK#04
CODE:
class Test{

public static void main(String[] args){

int i=0;
while(i<10){

System.out.println(i);

i++;

TASK#05
CODE:
class Test{

public static void main(String[] args){

int i=0;

do

System.out.println(i);

i++;

while(i<10);

}
LAB : 03
TASK#01
CODE:
class Car{

String name;

Car(){

name="By default";

Car(String name1){

name=name1;

public static void main(String[] args){

Car c=new Car();

System.out.println(c.name);

Car c1=new Car("Honda");

System.out.println(c1.name);

}
}

TASK#02
CODE:
class Student{

String name;

int roll_no;

int age;

double gpa;

String address;

Student(){

name="Misbah";

roll_no=76;

age=18;

gpa=4;

address="fjwu rawalpindi";

void read(){

System.out.println("read");

void write(){

System.out.println("write");

public static void main(String[] a){


Student obj=new Student();

System.out.println("Name:"+obj.name);

System.out.println("Roll-no:"+obj.roll_no);

System.out.println("Age:"+obj.age);

System.out.println("GPA:"+obj.gpa);

System.out.println("Address:"+obj.address);

obj.read();

obj.write();

TASK#03
CODE:
class Animal{

String name,colour;

int age;

Animal(){

name="Lion";

colour="Yellow";

age=4;

void play(){
System.out.println("Playing ");

void eat(){

System.out.println("Eating ");

void sleep(){

System.out.println("Sleeping ");

public static void main(String[] args){

Animal obj=new Animal();

System.out.println("NAME :"+obj.name+"COLOUR :"+obj.colour+"AGE :"+obj.age);

obj.play();

obj.eat();

obj.sleep();

LAB:04
TASK#01
CODE:
class My{

public static void main(String[] args){

String student[]={"x","y","z"};
for(String s:student){

System.out.println(s);

TASK#02
CODE:
import java.util.Date;

class Test{

public static void main(String[] args){

Date d=new Date();

System.out.println(d);

}}

TASK#03
CODE
public class Calculator{

void add(int a,int b){

System.out.println(a+b);

}
class Main_Calculator{

public static void main(String[] args){

Calculator obj=new Calculator();

obj.add(10,15);

TASK#04
CODE

LAB:05
TASK#01
CODE:
package animal;

public class Dog {


String gender,type,colour;
int age;

public String getGender() {


return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getColour() {
return colour;
}
public void setColour(String colour) {
this.colour = colour;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
void Sleep()
{
System.out.println("Sleeping");
}
void Eat(){
System.out.println("Eating");
}
void Play(){
System.out.println("Playing");
}
Dog(){

gender="female";
type= "german ";
colour="White";
age= 3;
}
}

package animal;

public class Test {

public static void main(String[] args) {


// TODO Auto-generated method stub
Dog d=new Dog();
System.out.println(d.getGender());
System.out.println(d.getType());
System.out.println(d.getColour());
System.out.println(d.getAge());
d.Sleep();
d.Eat();
d.Play();
}

OUTPUT:

TASK#2
CODE:
package plant;

public class Flower {


String name,colour,fragrance;

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}

public String getColour() {


return colour;
}

public void setColour(String colour) {


this.colour = colour;
}

public String getFragrance() {


return fragrance;
}

public void setFragrance(String fragrance) {


this.fragrance = fragrance;
}
Flower(){
name="rose";
colour="red";
fragrance="nice";
}
void grow(){
System.out.println("Growing");
}
void flower(){
System.out.print("Flowers");
}
}
package plant;

public class Test {


public static void main(String[] args){
Flower f=new Flower();
System.out.println(f.getName());
System.out.println(f.getColour());
System.out.println(f.getFragrance());
f.grow();
f.flower();
}

LAB#06

You might also like