0% found this document useful (0 votes)
93 views3 pages

Java OOP Exam Paper X10313

The document is a question paper for an examination on object oriented programming in Java. It contains 3 parts with multiple choice and long answer questions. Part A contains 10 short answer questions worth 2 marks each. Part B contains 5 long answer questions worth 13 marks each. Topics include OOP concepts in Java like inheritance, interfaces, exceptions and file handling. Part C contains 1 long answer question worth 15 marks to write a GUI application or address book class in Java.
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)
93 views3 pages

Java OOP Exam Paper X10313

The document is a question paper for an examination on object oriented programming in Java. It contains 3 parts with multiple choice and long answer questions. Part A contains 10 short answer questions worth 2 marks each. Part B contains 5 long answer questions worth 13 marks each. Topics include OOP concepts in Java like inheritance, interfaces, exceptions and file handling. Part C contains 1 long answer question worth 15 marks to write a GUI application or address book class in Java.
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

Reg. No.

:
*X10313*

Question Paper Code : X 10313


B.E./[Link]. Degree Examinations, november/decembeR 2020/
APRIL/MAY 2021
Third/Fourth/Fifth Semester
Computer Science and Engineering
cs 8392 – object oriented programming
(Common to : Computer and Communication Engineering/Electrical and
Electronics Engineering/Electronics and Communication Engineering/Electronics
and Instrumentation Engineering/Electronics and Telecommunication
Engineering/Instrumentation and Control Engineering/Information Technology)
(Regulations 2017)

Time : Three Hours Maximum : 100 Marks

Answer all questions


Part – A (10×2=20 Marks)
1. Define encapsulation in Java.
2. What is a constructor ?
3. Exemplify the use of super keyword.
4. What are the differences between classes and interfaces ?
5. What is the purpose of finally clause ? give example.
6. What are the uses of streams. What are the two types of streams ?
7. What is the need for synchronization ? How it can be implemented ?
8. How to create a single class, which automatically works with different types of
data ? Give example.
9. Write the sequence in which method calls takes place when an applet is terminated ?
Define those methods.
10. What are the two key features of swing ?

Part – B (5×13=65 Marks)


11. a) i) How Java changed the internet ? (9)
ii) If semicolons are needed at the end of each statement, why does the comment
line not end with a semicolon ? (4)
(OR)
b) What are the three categories of control statements used in Java ? Explain
each category with example. (13)
X 10313 -2- *X10313*

12. a) Write a Java program to calculate electricity bill using inheritance. The program
should get the inputs of watts per hour and unit rate.

Check your program for the following case :

Assume a consumer consumes 5000 watts per hour daily for one month. Calculate
the total energy bill of that consumer if per unit rate is 7 [1 unit = 1k Wh]. (13)
(OR)
b) What is interface ? With an example explain how to define and implement
interface. (13)

13. a) Write a short note on the following topics :

• Uncaught exceptions. (3)

• Difference between throw and throws. Give example for both. (5)

• Chained exceptions. Give example. (5)


(OR)
b) How to perform reading and writing files ? Explain with example. (13)

14. a) Discuss the different states of thread in detail. (13)


(OR)

b) i) What is the purpose of thread priorities ? What are the different thread
priorities that exist ? (5)

ii) What are bounded types ? Why it is used ? Give example. (8)

15. a) i) List any five different user interface components that can generate the
events. (5)

ii) Demonstrate any four mouse event handlers with example. (8)
(OR)
b) Describe how to work with graphics to display information within window. (13)
*X10313* -3- X 10313

Part – C (1×15=15 Marks)

16. a) Write an AWT GUI application (called AWT counter) as shown in the Figure 1.
Each time the “Count” button is clicked, the counter value shall increase by 1.

Figure 1
(OR)
b) Write an addressbook class that manages a collection of person object. An
addressbook will allow a person to add, delete, or search for a person object in
the address book.
• Add method : It should add a person object to the addressbook.
• Delete method: It should remove the specified person object from the book.
• Search method: It searches the address book for a specified person and returns
the list of persons matching the specified criteria. The search can be done either
by first name, last name or person id.

–––––––––––––

Common questions

Powered by AI

Java transformed internet programming by introducing capabilities that enabled browsers to dynamically execute programs within web pages through applets. This enabled richer user interactions and improved multimedia experiences. Java's platform independence and built-in security features made it ideal for developing network-centric applications that could run on any device with a Java Virtual Machine, significantly broadening the scope and functionality of internet applications.

The two key features of Swing are the lightweight component design and the pluggable look-and-feel architecture. Lightweight components do not rely on platform-specific code, allowing for a more flexible and consistent user interface across different platforms. The pluggable look-and-feel architecture allows developers to dynamically change the appearance of applications without altering their functionality. Together, these features enhance user interface development by offering greater control over the aesthetics and behavior of GUI components, leading to richer and more adaptable interfaces.

Encapsulation in Java contributes to software security and reliability by restricting direct access to some of an object's components, which can prevent the accidental modification of data. Encapsulation allows for modification of implemented code without breaking the code of others who use it, as these users are unaware of the hidden code. By defining clear interfaces and hiding implementation details, encapsulation helps maintain a well-structured code base, protecting object integrity and making software easier to manage and less error-prone.

The 'throw' keyword in Java is used to explicitly throw an exception within a method, typically to signal an error condition. Conversely, 'throws' is used in method signatures to declare that a method might throw one or several exceptions, informing the caller to anticipate and handle these potential exceptions. While both keywords relate to exception handling, 'throw' is used at runtime to trigger an exception, whereas 'throws' is a compile-time declaration of potential exceptions. Both are crucial for robust error handling, ensuring that Java applications can gracefully manage runtime anomalies.

Synchronization in Java multithreading is crucial for controlling access to shared resources by multiple threads, thereby preventing data inconsistency and race conditions. Its implementation is achieved using synchronized blocks or methods, which lock an object while a thread is executing a critical section, and release it once the execution is complete. This mechanism ensures that only one thread has access to the resource at any given time, promoting thread safety and data integrity.

The super keyword in Java is used to access methods and variables of a parent class, especially when overridden by child classes. This is instrumental in solving issues related to overriding and inheritance hierarchies, by allowing explicit invocation of a parent class's method, thus preserving the intended functionality of overridden methods and ensuring that the more general class behaviors are incorporated into the specialized subclasses.

The distinction between classes and interfaces in Java lies in their roles and structures. A class typically defines attributes and behaviors (methods) of objects and can include implementations of these methods. In contrast, an interface is a collection of abstract methods that can be implemented by any class, thereby allowing a form of multiple inheritance. This distinction facilitates software development by promoting loose coupling through the definition of clear contracts (interfaces), encouraging flexible and interchangeable implementations and enforcing certain behaviors across unrelated classes.

Bounded types in Java optimize generic programming by restricting the types that can be substituted for a parameter type using bounds, such as extending a particular class or implementing an interface. This is essential for optimizing code safety and reusability because it ensures that the generic type can be used in methods defined within the bounds, thus avoiding runtime errors and enabling code that is more resilient and easier to maintain. Bounded types permit developers to apply constraints, leading to more precise and meaningful type safety in generic constructs.

The 'finally' clause in Java serves a crucial role in exception handling by ensuring that important cleanup code is executed regardless of whether an exception is thrown or not. The significance of 'finally' lies in its guarantee of resource deallocation, such as closing file streams or releasing network connections, which is essential to maintain application stability and prevent resource leaks. By using 'finally', developers ensure that the program can continue running smoothly even after facing unexpected errors.

A thread in Java goes through several states: New, Runnable, Blocked, Waiting, Timed Waiting, and Terminated. A New thread is created but not yet started. In the Runnable state, it is ready to execute. Blocked threads are waiting to acquire a lock, while Waiting and Timed Waiting are for threads awaiting another thread's actions or timeout. Terminated threads have completed execution. Understanding these states is crucial for developers to effectively manage thread lifecycles and avoid concurrency issues, such as deadlocks and resource contention in multithreaded programs.

You might also like