You are on page 1of 6

1

Lab 1:

1. Write and run the source code given below.

a. What is a class name?


b. What is a file name?
c. What is a main method?
d. What does System.out.println(“World!”) do?

1
2

2. Class, Object and void method

A posible class name Posible object


Image
names
1. Write a java
application
based on the
class name.

2. Inside the
class, create one
void method
named display.
The method will
print the name
of the image.
Example “This is
a Car”

3. Write one
application
named
Main.java. the
Main.java
consists main
method. Create
objects of four
classes and
invoke display
method in Main
method.

3. Complete the MyFirstAnalysis.java below.

package firstanalysis;

import java.util.Random;

2
3

/**
*
* @author msa
*/
public class MyFirstAnalysis {

public int [] generateRandomData()


{
int inputData[] = new int[10];

Random generateRandom = new Random();


for(int i =0; i<10; i++)
{
inputData[i] = generateRandom.nextInt(100);
}

return inputData;

public void findMaxMinSumAverage(int [] inputData)


{
/*
* 1. Write your code to display Min, Max, Sum and Average Value
*
}

public static void main(String[] args) {

MyFirstAnalysis firstAnalysis = new MyFirstAnalysis();


for(int value : firstAnalysis.generateRandomData())
{
System.out.println("Values : "+value);
}
}
}

4. Based on the UML class given below, write the java implementation class. Then, write
MyApp.java given below. Compile and run MyApp.

3
4

MyApp.java

5. Write one class named Temperature.


6. Inside the temperature class, write one method to convert farenheit to celcius.

Method Name public double convertTemperaturetoCelcius(double fahrenheit)


Input of method double
process celcius = (5.0/9)*(fahrenheit-32)
Output Temperature in celcius

4
5

After finish question 5 and 6, run the Exercise1.java application below.

5
6

7. Add the related source code for converting farenheit to celcius into GuiTemperature class
below. Compile and run GuiTemperature.

You might also like