You are on page 1of 2

1.

Aim/Overview of the practical:


To write programs for the questions given below.

2. Task to be done: Worksheet Questions:


1. Create a program which counts number of objects created in a class.
2. Write a program to find the cube of a given number using the static method.

2. Code for experiment/practical:

Code for 1st Question:

public class Number_Objects


{ static int
count=0;
Number_Objects()
{
count++;
}
public static void main(String[] args)
{
Number_Objects obj1 = new Number_Objects();
Number_Objects obj2 = new Number_Objects();
Number_Objects obj3 = new Number_Objects();
Number_Objects obj4 = new Number_Objects();
System.out.println("Number of objects created:"+count);
}
}

Code for 2nd Question:

import java.util.*; public


class Cube {
public static void main(String args[]){
Scanner sc=new Scanner(System.in); int

System.out.print("Enter an integer number:


");
num=sc.nextInt(
);
System.out.println("Cube of "+ num + " is: "+ Math.pow(num,
3));
num;

}
}

3. Result/Output/Writing Summary:

Output of 1st Program:

Evaluation Grid:
Sr. No. Parameters Marks Obtained Maximum Marks
1. Demonstration and Performance 5
(Pre Lab Quiz)
2. Worksheet 10
3. Post Lab Quiz 5

You might also like