Quiz 2 B
Quiz 2 B
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.
______________________;
}
if(____________________________________________) return false;
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.
{_______________________________________________________________________}