0% found this document useful (0 votes)
32 views1 page

Quiz 2 B

Uploaded by

vamsi.d124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Quiz 2 B

Uploaded by

vamsi.d124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ESC101 : Fundamental of computing

Quiz 1(B) 25 September, 2008

Name :

Roll no : Section:
Duration : 15 minutes

Question 1 Fill in the blanks the method IsPrime whose parameter is a positive integer of type int, and it returns
true if the number is prime and returns false if the number is not prime.

public static ________ IsPrime(________ n)


{
__________ t = __________ ;

boolean flag = __________ ;

while(t*t __________ n && ____________________)


{
if(_______________) flag = false;

______________________;
}
if(____________________________________________) return false;

else return true;


}

Question 2. We want to create a class Box. The attributes of a box are its length, breadth, and width. It should
have two constructors :
Box(double x) : to construct a Box with its length, breadth and width equal to x.
Box(double x, double y, double z) : to construct a Box with length x, breadth y, and width z.
Note : you may assume that the constructor is called with appropriate arguments such that the
resulting box has length greater than or equal to both its breadth as well as its width.
You have to design a method Volume() which returns volume of the current box. You also have to
design a method CanEnclose(Box B) which returns true if the current Box can enclose the Box B
completely. Please fill in the blanks the following description of Box class. You have to ensure that
once a Box is created it should not be possible to change its length, breadth and width.

public class Box


{
_______ double length;

_______ double breadth;

________ double width;

public Box(double x) {______________________________________________}

public Box(double x, double y, double z)

{_______________________________________________________________________}

public double Volume() {___________________________________________}

public boolean CanEnclose(Box B)


{
if(___________________________________________________________________) return true;

else return false;


}
}

You might also like