Академический Документы
Профессиональный Документы
Культура Документы
1
IV B.Tech I Semester Regular Examinations, November 2007
OBJECT ORIENTED PROGRAMMING THROUGH JAVA
( Common to Electronics & Instrumentation Engineering, Electronics &
Control Engineering and Electronics & Telematics)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆
1. (a) How a for loop can be defined and used within the program? Explain with
suitable examples. [8]
(b) Explain the role of Java applets in designing a web page. [8]
Ramu
Hyd Weds Delhi
Geetha
6. Explain the interface Runnable and show how to implement the interface runnable
in the applet. [16]
8. (a) How many bytes does the following code write to file destfile? [4]
try {
FileOutputStream fos = new FileOutputStream(“destfile”);
DataOutputStream dos = new DataOutputStream(fos);
dos.writeInt(3);
dos.writeDouble(0.0001);
1 of 2
Code No: RR411006 Set No. 1
dos.close();
fos.close();
}
catch (IOException e) { }
(b) What is the result if you execute the code below in an empty directory? [4]
File f1 = new File(“dirname”);
File f2 = new File(f1,“filename”);
(c) What is the result of attempting to compile and execute the code fragment
below? Assume that the code fragment is part of an application that has
write permission in the current working directory. Also assume that before
execution, the current working directory does not contain a file called datafile.
try {
RandomAccessFile raf = new RandomAccessFile(“datafile”) ,“rw”;
BufferedOutputStream bos = new BufferedOutputStream(raf);
DataOutputStream dos = new DataOutputStream(bos);
dos.writeDouble(Math.PI);
dos.close();
bos.close();
raf.close();
} catch(IOException e) { } [4]
(d) A file is created with the following code:
FileOutputStream fos = new FileOutputStream(“datafile”);
DataOutputStream dos = new DataOutputStream(fos);
for (int i=0; i<500; i++)
dos.writeInt(i);
Write the code to read back the data from this file. [4]
⋆⋆⋆⋆⋆
2 of 2
Code No: RR411006 Set No. 2
IV B.Tech I Semester Regular Examinations, November 2007
OBJECT ORIENTED PROGRAMMING THROUGH JAVA
( Common to Electronics & Instrumentation Engineering, Electronics &
Control Engineering and Electronics & Telematics)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆
1. (a) How a for loop can be defined and used within the program? Explain with
suitable examples. [8]
(b) Explain the role of Java applets in designing a web page. [8]
2. (a) What is meant by overloading methods? What are the advantages of over-
loading concept? [8]
(b) Write a method find Area that can find the area of the circle/square/rectangle
using overloading concept. [8]
3. Write your own versions of the string methods for searching strings. [16]
Figure 5
6. Explain the life cycle of an applet and the methods involved. [16]
7. (a) Why do methods have to declare the exceptions they can throw? [5]
(b) List the benefits of exception handling over conventional means of error process-
ing? [6]
(c) Explain the significance of throw statement with an example? [5]
1 of 2
Code No: RR411006 Set No. 2
(a) FileInputStream
(b) FileOutputStream
(c) FileNotFoundException
(d) IOException.
⋆⋆⋆⋆⋆
2 of 2
Code No: RR411006 Set No. 3
IV B.Tech I Semester Regular Examinations, November 2007
OBJECT ORIENTED PROGRAMMING THROUGH JAVA
( Common to Electronics & Instrumentation Engineering, Electronics &
Control Engineering and Electronics & Telematics)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆
1. (a) Write down the syntax and execution procedure of different kinds of if state-
ments in Java. [8]
(b) Write a Java program to find the sum of all elements in the one dimensional
array. (Define a class representing array with necessary data members and a
method to find the sum) [8]
2. (a) What is meant by overloading methods? What are the advantages of over-
loading concept? [8]
(b) Write a method find Area that can find the area of the circle/square/rectangle
using overloading concept. [8]
4. Write a program to create 4 x 4 grid and fills it in with the 15 buttons, each lable
with its index. [16]
7. (a) Explain how exception handling mechanism can be used for debugging a pro-
gram. [8]
(b) Is it essential to catch all types of exceptions? Justify your answer. [8]
⋆⋆⋆⋆⋆
1 of 1
Code No: RR411006 Set No. 4
IV B.Tech I Semester Regular Examinations, November 2007
OBJECT ORIENTED PROGRAMMING THROUGH JAVA
( Common to Electronics & Instrumentation Engineering, Electronics &
Control Engineering and Electronics & Telematics)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆
4. Write a java program to print the fol1owing frame. The size increases when you
move from left to right. [16]
A A AAA A
B BB B B B
1 of 2
Code No: RR411006 Set No. 4
5. (a) Explain the class hierarchy of various window types. [8]
(b) Write down any event generators. [8]
7. (a) How do you create your own exception classes? Explain with the help of an
illustrative example. [8]
(b) Explain with the help of a case situation, how to catch and handle different
types of exceptions. [8]
8. (a) How many bytes does the following code write to file destfile? [4]
try {
FileOutputStream fos = new FileOutputStream(“destfile”);
DataOutputStream dos = new DataOutputStream(fos);
dos.writeInt(3);
dos.writeDouble(0.0001);
dos.close();
fos.close();
}
catch (IOException e) { }
(b) What is the result if you execute the code below in an empty directory? [4]
File f1 = new File(“dirname”);
File f2 = new File(f1,“filename”);
(c) What is the result of attempting to compile and execute the code fragment
below? Assume that the code fragment is part of an application that has
write permission in the current working directory. Also assume that before
execution, the current working directory does not contain a file called datafile.
try {
RandomAccessFile raf = new RandomAccessFile(“datafile”) ,“rw”;
BufferedOutputStream bos = new BufferedOutputStream(raf);
DataOutputStream dos = new DataOutputStream(bos);
dos.writeDouble(Math.PI);
dos.close();
bos.close();
raf.close();
} catch(IOException e) { } [4]
(d) A file is created with the following code:
FileOutputStream fos = new FileOutputStream(“datafile”);
DataOutputStream dos = new DataOutputStream(fos);
for (int i=0; i<500; i++)
dos.writeInt(i);
Write the code to read back the data from this file. [4]
⋆⋆⋆⋆⋆
2 of 2