0% found this document useful (0 votes)
42 views11 pages

CA3 OPP Question

Uploaded by

webdeveloper8722
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)
42 views11 pages

CA3 OPP Question

Uploaded by

webdeveloper8722
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
You are on page 1/ 11

Question Bank Java :

MODULE I:
1. Abstract Datatypes and their specification.
2. How to implement an ADT.
a. Concrete state space.
b. Concrete invariant
c. Abstraction function
d. Implementing operations by the Text example.

Datatypes, ADT, Concrete state space , concrete invariant, method, class, object, types of
variables, JDK|JRE|JVM, bytecode, interpreter, static method, static variable.
…………………………………………………………………………………

Conceptual Questions:
1. What is an Abstract Data Type (ADT)? How is it different from a Data Structure?
2. Explain the importance of encapsulation in ADTs. How does it enhance abstraction?
3. Why is the behavior of an ADT specified without specifying its implementation?
4. What are some advantages of using ADTs in software development?
5. How do ADTs support modularity and reusability in programming?
6. Explain the difference between ADTs and object-oriented programming concepts like
classes.
7. Why are preconditions and postconditions important in the formal specification of
ADTs?
8. Give an example of an ADT and describe its key operations and properties.
9. How can you prove the correctness of an ADT specification?
10. Explain the difference between the axiomatic specification and operational specification
of ADTs.
11. What is concrete state space? Give example.
12. What do you mean by concrete invariant?
13. What are the various datatypes available in java.
14. Define class and object. Give real life example and coding example.
15. Define JDK, JRE and JVM.
16. Define bytecode.
17. “bytecode is magic in java”. Explain and justify.
18. What is interpreter in java.
19. Write short notes on static method and static variable.
20. What is qualified association? Describe with an example.
21. What is an object? Why java is called an object oriented programming language?
22. Write short notes on link and association.
23. Define abstraction.
24. Compare procedural and object oriented programming.
25. Create a package and write a java file with four methods for four basic Arithmetic
operations such as addition, subtraction, multiplication and division. These methods should save
the file in the Package. Write one more program that imports the above file to use these four
methods.
26. Briefly explain the use of “super” and “this” keywords.
27. Differentiate between ‘==’ and ‘equals’ methods in the context of String object.

Practical Questions:
1. Describe the stack ADT and list its fundamental operations.
2. What is the queue ADT, and how does it differ from the stack ADT?
3. Define a list ADT and describe the different types of lists (e.g., singly linked, doubly
linked).
4. How would you formally specify the ADT for a priority queue?
5. What are the basic operations of a tree ADT, and what are some common types of tree
data structures?
6. How would you represent a graph ADT, and what are its key operations?
7. Can an ADT have multiple implementations? Give an example of how a stack ADT could
be implemented using arrays and linked lists.
8. Describe the formal specification of the queue ADT and how its operations are defined.
9. What is meant by the term 'initial state' in the specification of an ADT? Give an example.
10. How would you extend the formal specification of an ADT to handle exceptions or error
states, such as popping from an empty stack?
11. Give example of abstract function and how to implement its operation?
12. WAP in Java to create an object of a class that produces various geometric shapes. Find
the area of various shapes by creating an object and calling the methods required.

Advanced/Theoretical Questions:
1. How do algebraic specifications formalize the behavior of ADTs?
2. Compare and contrast the specification of mutable and immutable ADTs.
3. How can you model complex data structures like graphs using ADTs?
4. What are some of the limitations of using ADTs for large-scale system design?
5. Discuss the role of ADTs in formal verification and testing of software systems.
6. How can you formalize the behavior of ADTs using functional programming paradigms?
7. What challenges arise in specifying concurrent data structures as ADTs?
8. How do generics or parametric polymorphism affect the design and specification of
ADTs?
9. Explain how inheritance and ADTs differ in terms of abstraction and reuse.
10. Describe how ADTs handle recursive data structures such as trees or linked lists.

MODULE II:
1 1. Features of Object Oriented Programming.
a. Encapsulation
b. Object identity
c. Polymorphism
Definition and examples of Encapsulation, Object identity, abstraction , Polymorphism ,
mehod overloading, constructor overloading, this, call by value, call by reference, varargs
method, Arrays, Strings.
1. What is encapsulation in Java, and how does it contribute to data security?
2. How is encapsulation implemented in Java through classes and access modifiers?
3. Can you explain the concept of getter and setter methods in relation to encapsulation?
4. How does encapsulation help in improving code maintainability and reusability?
5. What is object identity in Java, and how does it differ from object equality?
6. How does the hashCode() method relate to object identity in Java?
7. What role does the equals() method play in comparing object identities in Java?
8. What is polymorphism in Java, and how is it achieved through method overloading and method
overriding?
9. Can you explain the difference between compile-time and runtime polymorphism in Java?
10. How does polymorphism improve code flexibility and extensibility in Java applications?
11. What are object oriented Principle in Java?
Encapsulation
1. What is encapsulation, and why is it important in object-oriented programming?
2. How do access modifiers like private, protected, and public facilitate encapsulation in
Java?
3. Provide an example of encapsulation using getter and setter methods.
4. How does encapsulation improve security and modularity in a Java program?
Object Identity
5. What is object identity in Java, and how is it different from object equality?
6. How does Java distinguish between two different objects even if they contain the same
data?
7. Explain the significance of the hashCode() method in relation to object identity.
8. What is the difference between == operator and equals() method when comparing
objects?
Abstraction
9. What is abstraction in Java, and how does it differ from encapsulation?
10. How can you achieve abstraction using abstract classes in Java? Provide an example.
11. What role do interfaces play in achieving abstraction in Java?
12. Why is abstraction important in hiding implementation details from the user?
Polymorphism
13. Define polymorphism in Java, and explain the difference between static and dynamic
polymorphism.
14. What is method overriding, and how does it relate to runtime polymorphism in Java?
15. Provide an example of method overriding that demonstrates polymorphism.
16. How does polymorphism contribute to code flexibility in Java?
Method Overloading
17. What is method overloading in Java, and how does it differ from method overriding?
18. Provide an example of method overloading with different parameter lists.
19. Can overloaded methods have different return types in Java?
20. How does method overloading contribute to code readability and reusability?
Constructor Overloading
21. What is constructor overloading, and why is it useful in Java?
22. Provide an example of constructor overloading in a Java class.
23. How does constructor overloading improve flexibility when creating objects in Java?
this Keyword
24. What is the purpose of the this keyword in Java, and when is it used?
25. How does the this() constructor call work in Java, and how does it simplify code?
Call by Value and Call by Reference
26. What is the difference between call by value and call by reference in Java?
27. How does Java handle method arguments? Is it call by value or call by reference?
28. Provide an example to explain how changes to an argument inside a method affect the
original variable.
Varargs Method
29. What is a varargs method in Java, and how does it differ from passing an array as an
argument?
30. Provide an example of a varargs method and explain how it simplifies method calls.
Arrays
31. How are arrays declared and initialized in Java?
32. What are the advantages and disadvantages of using arrays in Java?
33. How can you iterate over an array using a for-each loop in Java? Provide an example.
Strings
34. What is the difference between String, StringBuilder, and StringBuffer in Java?
35. How does the immutability of strings in Java affect memory usage?
36. Provide an example of concatenating strings using the + operator and StringBuilder class.
37. What are some common string manipulation methods in Java (e.g., substring(), charAt(),
length())?

MODULE III:
1. Inheritance in OO design.
a. Deign Patterns
b. Introduction and classification.
c. The iterator pattern

What are design pattern for applying inheritance in object oriented programming,
Wrapper class, Various classification of Inheritance, method overriding, super, super(),
final,(for iterator pattern:) composition-association-aggregation, is-A, has-A, for loop, for-
each loop,[Collection iterator in Collection topic] , abstract class, abstract method,
interface, dynamic method dispatch, inner class, anonymous class.

Inheritance in Object-Oriented Design


1. What is inheritance in object-oriented design, and why is it important?
2. How does inheritance promote code reusability in Java?
3. What is the difference between single inheritance and multiple inheritance? How does
Java handle multiple inheritance?
4. What are the drawbacks of inheritance in object-oriented programming?
5. What are the different types of inheritance in Java (e.g., single, multilevel, hierarchical)?
6. What is method overriding, and how is it used in the context of inheritance?
7. How does the super keyword work in Java, and how is it related to inheritance?
8. What is the purpose of super() in constructors, and when would you use it?
9. What are the rules for method overriding in Java?
Design Patterns
10. What are design patterns, and why are they important in object-oriented design?
11. Explain the classification of design patterns into creational, structural, and behavioral
categories.
12. How does the Factory Design Pattern relate to inheritance in Java?
13. How is the Singleton pattern implemented in Java, and how does inheritance impact it?
14. Can you explain the Adapter design pattern and how inheritance and composition are
used together?
15. What is the Decorator design pattern, and how does it make use of inheritance or
interfaces?
The Iterator Pattern
16. What is the iterator design pattern, and how is it used in Java?
17. What is the difference between an iterator and a for-each loop in Java?
18. How does the Iterator interface work in Java’s Collection Framework?
19. What is the difference between hasNext() and next() methods in the Iterator interface?
20. Explain how the iterator pattern helps in decoupling the traversal algorithm from the
collection itself.
21. How do you create a custom iterator in Java for a non-Collection object?
Design Patterns and Inheritance
1. What are design patterns, and how do they apply to inheritance in object-oriented
programming?
2. How does the Factory Pattern utilize inheritance in Java?
3. What is the Singleton Pattern, and how can it be implemented using inheritance?
4. Explain the concept of the Adapter Pattern and its relation to inheritance.
5. How does the Strategy Pattern use inheritance to promote flexibility?
6. What is the Template Method Pattern, and how does it relate to inheritance and method
overriding?
7. Describe the Observer Pattern and how inheritance can be applied within this design.
8. What role does inheritance play in the Decorator Pattern?
Wrapper Class
9. What is a wrapper class in Java, and why is it necessary?
10. How do auto-boxing and unboxing work with wrapper classes?
11. Can you explain the difference between primitive types and their corresponding wrapper
classes?
12. How do wrapper classes facilitate operations with collections?
Classification of Inheritance
13. What are the various classifications of inheritance in object-oriented programming?
14. How does Java handle multiple inheritance, and what are the implications?
15. What is the difference between single and multilevel inheritance in Java?
16. Can you explain hierarchical inheritance with an example in Java?
Method Overriding
17. What is method overriding, and how is it used in inheritance?
18. What are the rules for method overriding in Java? What is dynamic method dispatch in
Java? Explain with an example.
19. How does the @Override annotation enhance code readability and safety?
20. What happens if you try to override a final method?
Super Keyword and super() Constructor
21. What is the purpose of the super keyword in Java?
22. How does super() differ from super when calling a constructor?
23. Can super() be used to call a non-default constructor? Explain with an example.
24. What happens if a class does not explicitly call super() in its constructor?
Final Keyword
25. What is the purpose of the final keyword in Java?
26. Can a final class be subclassed? Why or why not?
27. Can a final method be overridden? Explain the reasoning.
28. How does declaring a variable as final affect its behavior?
Composition, Association, and Aggregation
29. What is the difference between composition, association, and aggregation in object-
oriented design?
30. How does composition differ from inheritance in terms of design principles?
31. What is an example of an is-A relationship in Java?
32. What is an example of a has-A relationship in Java?
Loops
33. What is the difference between a for loop and a for-each loop in Java?
34. When should you use a for-each loop instead of a traditional for loop?
35. How does the for-each loop simplify array and collection traversal?
Collections and Iterators
36. What is the role of the Iterator interface in Java’s Collection Framework?
37. How do you create a custom iterator for a collection in Java?
38. What are the main methods of the Iterator interface, and what do they do?
39. Explain how the List Iterator interface differs from the Iterator interface.
Abstract Classes and Interfaces
40. What is the difference between an abstract class and an interface in Java?
41. How does an abstract class allow for method overriding, and what restrictions exist?
42. Can an interface extend multiple other interfaces? Provide an example.
43. What is the significance of the default method in interfaces introduced in Java 8?
Dynamic Method Dispatch
44. What is dynamic method dispatch, and how does it relate to inheritance in Java?
45. Can you provide an example of dynamic method dispatch using overridden methods?
46. How does dynamic method dispatch enable polymorphism in Java?
Inner Classes and Anonymous Classes
47. What is an inner class, and how does it differ from a regular class?
48. What are the advantages of using inner classes in Java?
49. What is an anonymous class, and when would you use one?
50. Can anonymous classes extend a class or implement an interface? Provide an example.

Module IV:

1. Model-view-controller pattern.
2. Commands as methods and as objects.
3. Implementing OO language feature.
4. Memory management.

Model-view-contoller pattern, Command as methods and as objects, Exception handling,


Multithreading, FILEs in Java, Sandbox security, Garbage collection, finalize method.

Model-View-Controller (MVC) Pattern


1. What is the Model-View-Controller (MVC) pattern, and what are its main components?
2. How does the MVC pattern promote separation of concerns in application development?
3. What role does the Model play in the MVC architecture?
4. How does the View component interact with the Model and Controller in an MVC
application?
5. What responsibilities does the Controller have in the MVC pattern?
6. Can you explain how data flows between the Model, View, and Controller in a typical MVC
application?
7. What are some common frameworks in Java that implement the MVC pattern (e.g., Spring
MVC)?
8. How does the MVC pattern facilitate unit testing in Java applications?
Commands as Methods and as Objects
9. What is the Command pattern, and how does it relate to encapsulating method calls?
10. How can commands be implemented as methods in Java?
11. What are the advantages of using commands as objects in Java?
12. Can you provide an example of a Command pattern implementation in Java?
13. How does the Command pattern enable undo functionality in applications?
Implementing Object-Oriented Language Features
14. What are the core principles of object-oriented programming (OOP)?
15. How do encapsulation, inheritance, and polymorphism work together in Java?
16. What are some common design patterns that facilitate the implementation of OOP
principles in Java?
17. How does Java support abstraction, and what constructs are used for it (e.g., abstract
classes, interfaces)?
18. Can you explain the role of inner classes in supporting object-oriented design in Java?
Memory Management
19. How does Java handle memory management, and what is the role of the Java Virtual
Machine (JVM) in this process?
20. What is garbage collection, and how does it work in Java?
21. What are the different garbage collection algorithms used by the JVM?
22. How can developers influence garbage collection in Java applications?
23. What are some best practices for memory management in Java to avoid memory leaks?
24. How do strong references, weak references, and soft references differ in Java?
25. Can you explain the significance of the finalize() method in Java, and how it relates to
garbage collection?
Exception Handling
1. What is exception handling in Java, and why is it important?
2. What are the main types of exceptions in Java?
3. How do you create a custom exception in Java? Explain the user defined exception and
system defined exception with suitable example.
4. What is the difference between checked and unchecked exceptions?
5. How do you use a try-catch block in Java to handle exceptions?
6. What is the purpose of the finally block in exception handling?
7. How does the throw keyword work in Java?
8. Can you explain the difference between throw and throws?
9. What happens if an exception is not caught in Java?
10. How can you create a chained exception in Java?
Multithreading
11. What is multithreading, and how does it improve the performance of Java applications?
12. What are the main differences between Thread class and Runnable interface? Draw and
explain life cylcle of a thread.
13. How do you create a thread in Java using the Runnable interface?
14. What is thread synchronization, and why is it necessary?
15. How can you achieve thread synchronization using synchronized methods and blocks?
16. What is a deadlock, and how can it be avoided in Java?
17. What is the purpose of the join() method in thread management?
18. How does the volatile keyword affect variable visibility in multithreaded applications?
19. What are the different thread states in Java, and how do they change?
20. How can you create a thread pool in Java?
File Handling
21. How do you read and write files in Java using the File class?
22. What is the difference between FileInputStream and FileReader in Java?
23. How can you handle binary and text files in Java?
24. What are the advantages of using BufferedReader and BufferedWriter?
25. How do you handle exceptions when performing file operations?
26. What is the purpose of the try-with-resources statement in Java?
27. How can you serialize and deserialize objects in Java?
28. What is the java.nio package, and how does it improve file handling?
Sandbox Security
29. What is the concept of sandbox security in Java?
30. How does the Java Security Manager enforce sandbox security?
31. What are the key components of the Java security architecture?
32. How can you implement security policies for Java applications?
33. What role do code signing and certificates play in sandbox security?
34. How does Java handle untrusted code in the context of applets?
Garbage Collection
35. What is garbage collection in Java, and how does it work?
36. What are the different types of garbage collection algorithms used in Java?
37. How can you monitor garbage collection activity in a Java application?
38. What is the role of the Java Virtual Machine (JVM) in garbage collection?
39. How do strong, weak, soft, and phantom references differ in Java?
40. What are some best practices for managing memory and minimizing garbage collection
overhead?
Finalize Method
41. What is the finalize() method in Java, and when is it called?
42. How does the finalize() method relate to garbage collection?
43. Why is it generally recommended to avoid using the finalize() method?
44. What are some alternatives to the finalize() method for resource management?
45. How can you override the finalize() method in a custom class?
General Questions
46. How can you handle multiple exceptions in a single catch block?
47. What is the purpose of the throwable class in Java exception handling?
48. How do you create a thread-safe singleton class in Java?
49. What are the differences between InputStream and Reader classes in Java?
50. How can you use Java's ExecutorService for managing threads?

MODULE V:
1. Generic types
2. Collections
3. GUIs. Graphical Programming with Scale and Swing.

Generic types, Collections, GUIs Applet(life cycle and few basic commands), AWT, Swing.

Introduction to Generics
1. What are generics in Java, and why are they used?
2. How do generics enhance type safety in Java?
3. What is the syntax for defining a generic class in Java?
4. Can you explain the difference between a generic class and a generic interface?
5. What is a type parameter in Java generics, and how is it declared?
Generic Methods
6. How do you define a generic method in Java?
7. What is the purpose of the <T> notation in generic methods?
8. Can generic methods have multiple type parameters? Provide an example.
9. How does type inference work with generic methods?
Bounded Type Parameters
10. What are bounded type parameters in Java generics?
11. How do you define a bounded type parameter using the extends keyword?
12. Can you provide an example of a bounded type parameter with multiple bounds?
13. What happens if you try to use a type that does not meet the bounds specified in a
generic type?
Wildcards
14. What are wildcards in Java generics, and when are they used?
15. What is the difference between an unbounded wildcard and a bounded wildcard?
16. How do you declare an unbounded wildcard using the ? symbol?
17. Can you explain the use of the ? extends T and ? super T wildcards?
18. When would you use a ? super T wildcard in a method signature?
Type Erasure
19. What is type erasure in Java generics?
20. How does type erasure affect the use of generics at runtime?
21. What are the implications of type erasure on generic type parameters and casting?
Generic Collections
22. How do generics improve the use of Java Collections Framework (e.g., List, Map)?
23. What is the difference between List<T> and List<Object> in Java?
24. How do you create a generic method that operates on a collection of a specific type?
Common Issues and Best Practices
25. What are some common pitfalls when using generics in Java?
26. How can you prevent type-safety issues when using generics?
27. What are some best practices for naming type parameters in generic classes and
methods?
Advanced Topics
28. Can you use primitive types (e.g., int, char) as type parameters in generics?
29. How can you use generics with inheritance in Java?
30. What are some real-world applications of generics in Java programming?

Collections

Basic Questions:
1. What is the Java Collection Framework?
2. What is the difference between a Collection and a Collections class in Java?
3. What are the main interfaces of the Java Collections Framework?
4. What is the difference between List, Set, and Map in Java?
5. What is the difference between ArrayList and LinkedList?
6. What is the difference between HashSet and TreeSet?
7. What is the difference between HashMap and TreeMap?
8. What is the difference between HashMap and Hashtable?
9. How does the Iterator interface work in Java?
10. What is the difference between Iterator and ListIterator?
11. What is the difference between fail-fast and fail-safe iterators in Java?
12. What is the difference between Collection and Collections framework in Java?
Advanced Questions:
13. How does HashMap work internally?
14. What is hashing in Java?
15. What is the load factor in HashMap?
16. Why is the initial capacity of a HashMap always a power of two?
17. How does ConcurrentHashMap work internally?
18. How are collisions handled in a HashMap?
19. What is the difference between synchronized and concurrent collections in Java?
20. What are the different types of queues available in the Java Collections Framework?
21. What is the difference between ArrayList and Vector?
22. What are weak references and how does WeakHashMap work?
23. What are the thread-safe versions of collections in Java?
24. What is the difference between Comparable and Comparator interfaces?
25. How can you make a Collection read-only?
26. How does the Collections.sort() method work?
27. What is the difference between LinkedHashMap and HashMap?
28. What is the EnumSet and how is it different from a HashSet?

Performance and Best Practices:


29. What are the advantages and disadvantages of using ArrayList over LinkedList?
30. What is the difference between TreeMap and LinkedHashMap in terms of performance?
31. What is the time complexity for common operations (insert, delete, access) in
collections like ArrayList, LinkedList, HashSet, TreeSet, HashMap?
32. What is the difference between a synchronized collection and a concurrent collection?
33. Why should we avoid using Vector in modern Java applications?
34. What is a BlockingQueue and how does it work?
35. How would you design a custom Collection class in Java?
GUIs. Graphical Programming with Scale and Swing.
Basic Questions:
1. What is Swing in Java?
2. What is the difference between AWT and Swing in Java?
3. What is the JFrame class in Swing?
4. How do you create a basic window using JFrame?
5. What are the key components in the Swing library?
6. What is a JPanel and how is it used in Swing?
7. What is the difference between a JPanel and a JFrame?
8. What is a JButton and how do you add a button to a Swing application?
9. How do you add an event listener to a Swing component?
10. What is the ActionListener interface, and how is it used in Swing?
11. What is the purpose of the LayoutManager in Swing?
12. What are the different layout managers available in Swing?
13. How does BorderLayout work in Swing?
14. How does GridLayout work in Swing?
15. What is a JLabel and how do you add it to a frame?
16. What is the role of JTextField in Swing, and how do you handle user input?
17. What is a JTextArea, and how does it differ from JTextField?
18. What are JCheckBox and JRadioButton, and how are they used in a GUI?
19. How do you create a drop-down list using JComboBox?
20. What is a JTable, and how do you create a simple table in Swing?
21. What is AWT? What is Event Listener?
Intermediate Questions:
21. How do you handle events like mouse clicks in Swing?
22. What is a JMenuBar, and how do you add a menu to a Swing application?
23. How do you create a custom component in Swing?
24. How do you manage component resizing in a Swing application?
25. What are the differences between repaint(), revalidate(), and invalidate() in Swing?
26. What is the Event Dispatch Thread (EDT) in Swing, and why is it important?
27. How do you perform long-running tasks in the background using SwingWorker?
28. How can you display a dialog box using JOptionPane?
29. How do you create a file chooser dialog using JFileChooser?
30. What are JScrollPane and JSplitPane, and how are they used in a GUI?
Advanced Questions:
31. How do you create a responsive GUI using Swing?
32. What is double buffering in Swing, and why is it used?
33. How do you perform custom painting in Swing using the paintComponent() method?
34. How can you create a multi-window Swing application?
35. How does Java Swing interact with the underlying operating system's GUI system?

You might also like