[go: up one dir, main page]

0% found this document useful (0 votes)
46 views4 pages

Java QP - BCS306A

Java questions bank

Uploaded by

gaganrai2005.05
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)
46 views4 pages

Java QP - BCS306A

Java questions bank

Uploaded by

gaganrai2005.05
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/ 4

OBJECT ORIENTED PROGRAMMING WITH JAVA- BCS306A

Unit-1

1. Explain the difference between procedural programming and object-oriented


programming.
2. List and describe the three main principles of object-oriented programming.
3. List five Java keywords and explain their purpose.
4. Explain different types of literals with an example program.
5. How do lexical issues like improper use of whitespace and incorrect identifiers
affect Java code readability and maintainability? Or Explain different lexical issues
in JAVA.
6. Explain the difference between implicit type conversion and explicit type casting.
Provide examples.
7. Describe how automatic type promotion works in expressions involving different
data types.
8. Explain primitive datatype with an example program.
9. List and describe the purpose of arithmetic operators in Java. Provide examples of
their usage.
10. What is the ternary (?) operator, and how is it used? Provide a code example.
11. Explain the difference between relational operators and boolean logical operators.
12. Describe the role of operator precedence in evaluating expressions. How can
parentheses be used to alter precedence?
13. How does a switch statement work in Java? Provide an example with multiple
cases and a default case.
14. What is the difference between a while loop and a do-while loop? Provide
examples of each.
15. Explain how the for-each loop simplifies iteration over arrays or collections.
16. What are the purposes of the break, continue, and return statements in Java?
Provide examples.
17. Explain different types of for loop in java with an example program.
18. Develop a JAVA program to add TWO matrices of suitable order N (The value of N
should be read from command line arguments).
19. Develop a stack class to hold a maximum of 10 integers with suitable methods.
Develop a JAVA main method to illustrate Stack operations.

Unit-2

1. Explain the basic components of a java class with an example program.


2. How do you declare and instantiate an object in Java? Provide an example.
3. Explain the purpose of constructors in Java. How do they differ from regular
methods?
4. What is the this keyword in Java, and how is it used within a class? Provide an
example.
5. Design a class with multiple constructors demonstrating constructor overloading.
Explain how each constructor can be used in different scenarios.
6. Analyze the benefits and potential issues of using the this keyword in a class with
complex logic or inheritance.
7. How do you overload methods in Java? Provide a code example showing
overloaded methods.
8. Describe how recursion works in Java. Provide a simple recursive method example
9. What is the purpose of the static keyword in Java? Provide an example of a static
method or variable.
10. Explain the difference between final variables, methods, and classes in Java.
11. Develop a class with overloaded methods and explain how method overloading
enhances flexibility and readability in your program.
12. Discuss the advantages and limitations of using static members in a class. When
should you prefer static methods or variables over instance methods?
13. What is the difference between a nested class and an inner class in Java? Provide
examples of each.
14. How do you access a member of an inner class from an outer class? Provide a code
example.
15. What are constructors? Explain two types of constructors with an example
program.
16. Define recursion. Write a recursive program to find nth Fibonacci number.
17. Explain the various access specifiers in Java.
18. Explain call by value and call by reference with an example program
19. Write a program to perform Stack operations using proper class and Methods.
20. Explain the use of this in JAVA with an example.
21. Program 3-5

Unit-3

1. Write a Java program to implement multilevel inheritance with 3 levels of


hierarchy.
2. Explain how an interface is used to achieve multiple Inheritances in Java.
3. Explain the method overriding with a suitable example.
4. What is single-level inheritance? Write a Java program to implement single-level
inheritance.
5. What is the importance of the super keyword in inheritance? Illustrate with a
suitable example.
6. What is abstract class and abstract method? Explain with an example.
7. Explain the basic concept of inheritance in Java. How does it help in reusing code?
8. What is the purpose of the super keyword in Java? Provide an example of its usage.
9. Describe how constructors are executed in a multilevel inheritance hierarchy.
10. What is method overriding, and how does it differ from method overloading?
Provide an example.
11. Explain dynamic method dispatch in Java. How does it enable runtime
polymorphism?
12. What is an interface in Java, and how is it different from an abstract class? Provide
an example.
13. Explain the purpose of default methods in interfaces. How do they improve
interface design?
14. How can static methods be used in interfaces? Provide a code example.
15. What is the purpose of private methods in interfaces? How do they help in
maintaining the code?
16. Design a Java program that demonstrates method overriding and dynamic method
dispatch. Explain how polymorphism is achieved in your example.
17. Program 5-8

Unit-4

1. What are the basic principles of exception handling in Java? Describe the role of
try and catch blocks.
2. Explain the difference between checked and unchecked exceptions. Provide
examples of each.
3. What is the purpose of the finally block in exception handling? When is it executed?
4. How do you create a custom exception subclass in Java? Provide a code example.
5. What is a package in Java, and why is it used? Provide an example of how to create
a package.
6. Explain the differences in member access levels (public, protected, default,
private) when using packages.
7. How do you import a package in Java? Provide an example using the import
statement.
8. What is the significance of the java.lang package, and why do you not need to
import it explicitly?
9. Develop a Java program that demonstrates multiple catch clauses and nested try
statements. Explain how each clause handles different exceptions.
10. Analyze the use of the throw and throws keywords in exception handling. How do
they contribute to the robustness of a Java application?
11. What are the steps to create a package and add classes to it in Java? Provide a
detailed example.
12. Describe how the protected access modifier works within and outside of packages.
13. Explain the difference between importing a single class and importing an entire
package in Java.
14. What is the purpose of the static import statement? How does it differ from the
regular import statement? Provide an example.
15. How does Java differentiate between runtime exceptions and compile-time
exceptions? Provide examples of each.
16. What is an uncaught exception, and what happens when it occurs in a Java
program?
17. Explain the significance of the throws keyword in method declarations. How does
it affect method callers?
18. Describe a scenario where the finally block is critical for resource management.
19. Program 9 and 10

Unit 5

1. What is the Java Thread Model, and how does it support concurrent execution?
2. Explain how to create a thread in Java using the Thread class. Provide a code
example.
3. What is the role of the main thread in a Java application? How can additional
threads be created?
4. How do the isAlive() and join() methods work in managing thread execution?
Provide examples.
5. Explain how thread priorities influence the execution of threads. How can you set
the priority of a thread?
6. What is synchronization in multithreading, and why is it important? Provide an
example of synchronized methods.
7. Describe the process of inter-thread communication in Java using wait(), notify(),
and notifyAll().
8. How can threads be suspended, resumed, and stopped in Java? Why are these
methods generally discouraged?
9. Explain how to obtain and interpret a thread’s state using the getState() method.
10. Describe how to create multiple threads and manage their execution. Provide an
example demonstrating concurrent execution.
11. What is an enumeration in Java, and how do you define one? Provide an example.
12. Explain the values() and valueOf() methods in enumerations. How are they used?
13. Describe the purpose of type wrappers in Java. List the common type wrapper
classes.
14. What is autoboxing in Java, and how does it simplify working with primitive types
and objects? Provide an example.
15. Explain how autoboxing/unboxing works in method calls. Provide a code example
demonstrating this concept.
16. How does autoboxing/unboxing occur in expressions? Provide an example
showing the interaction between primitive types and their wrapper classes.
17. Describe the process of autoboxing/unboxing Boolean and Character values.
Provide examples.
18. What are the key differences between primitive types and their corresponding
type wrappers?
19. Explain how enumerations can be used in switch statements. Provide an example.
20. How can you use type wrappers to convert between primitive types and their
string representations? Provide examples.
21. Program 11 and 12

You might also like