Term-End Examination
December, 2006
CS-74: INTRODUCTION TO INTERNET PROGRAMMING
Time : 3 hours Maximum Marks : 75
Note : Question number 1 is compulsory. Answer any three questions from the rest.
1. (a) What is the difference in run-time polymorphism and compile-time polymorphism ? Explain with the help of suitable example. (10)
(b) What is the difference between Applets and an Application program in java ? Explain. (5)
(c) What is the advantage of finally block in java ? Explain with suitable example. (6)
(d) Write a program for I/O operation using Buffered Input Stream and Buffered Output Stream.(5)
(e) Will an error occur if a class with the same name exists in two different packages that you import using * form ? How can the error be avoided ? (4)
2. (a) Write a program in java to design a class complex for complex number of the form a + ib. Write an overload operator + to add two complex numbers. (8)
(b) What is finalize() method in java ? Explain. (3)
(c) Explain the use of this keyword in java with the help of a suitable example. (4)
3. (a) Write a program in java to generate the following output, using two-dimensional array (6)
0
1 2
3 4 5
6 7 8 9
(b) What is the use of super keyword in java ? Explain with suitable example. (5)
(c) What is package in java ? If a class with default access is defined in a package pl, discuss the access rights of this class in another package p2.
4. (a) Differentiate between interfaces and abstract classes in java with the help of suitable example. (8)
(b) Write a program in java to display a text file where name of the file is given at command line.(7)
5. (a) Write a program in java to sort a list of n numbers using any sorting method for a given input n.(6)
(b) Find the output of the following
(i) Class X {
static int a = 4;
static int b;
static void f (int x)
{
system.out.println (" x =" +x);
system.out.println ("a =" +a);
system.out.println (" b =" +b);
}
static {
b a * 2;
}
public static void main (string args [ })
{
f (20);
}
} (5)
(ii) Class Break Demo }
public static void main (string args } ))
{
outer for (int i = 0; i < 3; i++)
{
system. out. print (" Pass" +i +
for (int j = 0; j < 100; j++)
{ if (j == 10) break outer;
system. out. print (j +
}
system.out.println (" Break Demo");
}
system.out.println ("Loops Complete"); (4)