Вы находитесь на странице: 1из 7

Code No: RR411006 Set No.

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]

2. (a) What is a class ? How does it accomplish data hiding ? [6]


(b) Explain the difference between an object and a class. [6]
(c) What is a constructor ? what are its special properties ? [4]

3. (a) List the advantages of package. [3]


(b) Write a Java program to implement Hierarchical inheritance. [10]
(c) List the advantages of interface. [3]

4. Write a java program to design a border layour as shown below. [16]

Ramu
Hyd Weds Delhi
Geetha

5. (a) Explain the class hierarchy of various window types. [8]


(b) Write down any event generators. [8]

6. Explain the interface Runnable and show how to implement the interface runnable
in the applet. [16]

7. (a) What is the difference between multiprocessing and multithreading? What is


to be done to implement these in a program? [8]
(b) What is the difference between suspending and stopping a thread? List out
the methods used to block a thread? [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);

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]

4. (a) Describe the arguments used in the method drawRoundRect ( ) [8]


(b) Explain the purpose of each argument used in the method draw Arc( ) [8]

5. Write a java program to design a dialog box as shown figure 5. [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]

8. Write a short note on the following: [4 × 4]

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]

3. (a) When do we declare a method or class final and abstract. [5]


(b) Discuss the different levels of access protection available in Java. [5]
(c) What is inheritance and how does it help to create new classes quickly. [6]

4. Write a program to create 4 x 4 grid and fills it in with the 15 buttons, each lable
with its index. [16]

5. (a) Explain the class hierarchy of various window types. [8]


(b) Write down any event generators. [8]

6. Write an applet which demonstrates the use of scrollbars. [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]

8. (a) Summarize the list of byte stream classes. [8]


(b) Summarize the list of the character stream I/O classes. [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
⋆⋆⋆⋆⋆

1. (a) Discuss the different types of literals available in Java. [8]


(b) Write about automatic type conversion and explain when casting is needed?
[8]

2. (a) What is a class ? How does it accomplish data hiding ? [6]


(b) Explain the difference between an object and a class. [6]
(c) What is a constructor ? what are its special properties ? [4]

3. (a) Consider two calls


Public class D extends B
{ Public void f( )
{ this.g( ); // 1
}
public void g( )
{ super.g( ) //2
}
. . . .
}
Which one of them is an example of early binding ? Which one of them is an
example of late binding ? Explain. [5]
(b) Explain the term shallow copy and deep copy. [5]
(c) Implement a super class Person. Make Y two classes , Student and Instructor.
Inherit from Person. A person has a name and a year of Birth. A student
has a major and an instructor has a salary. Write the Class definitions , the
constructors. [6]

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]

6. Write an applet which demonstrates the use of scrollbars. [16]

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

Вам также может понравиться