11/24/2013

BCS2233 OOP: Quiz 2

1. TRUE / FLASE (5 Marks)



a) A Java class uses variables to define data fields and methods to define behaviors.(T/F)
b) An object is an instance of a class. (T/F)
c) You use the new operator to create an object.(T/F)
d) The dot (.) operator to access members of that object through its reference variable.(T/F)



2. Consider the following java code. Draw the UML diagram for the class cubee.(5 Marks)


import java.util.Scanner;

public class class1_triangle {
  
    public static void main(String[] args) {
      
           cubee mycube= new cubee();
        mycube.inputdata();
      
        System.out.println("Area of a cube is " + mycube.get_area());
        System.out.println("Perimeter of a cube is " + mycube.get_parameter());     
    }
}


class cubee
{
   int width;


void inputdata()
{
   System.out.println("Please enter width of a cube ");
   Scanner input = new Scanner(System.in);
   width = input.nextInt();

}

double get_area()
{
   return (width * width*width);
}


double get_parameter()
{
   return width*12;
}

}



No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...