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

Java Programming Question Bank Guide

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Java Programming Question Bank Guide

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Programming in Java

I MCA
Question Bank

Unit I

Part A

What are the core OOP’s concepts?


Identify access modifiers in Java with examples.
What are Lexical Issues?
Define Variable.
Differentiate Overloading Methods and Overloading Constructors.

Part B

Describe in detail the various control structures in java.


Write a program to implement Fibonacci series.
Describe Object oriented concepts of Java
Explain Java Buzzwords in detail
Define array. Explain the types of array with example.
Explain the various features of Object-Oriented Concepts in java
Explain java operator. List the various operators in java with suitable example.

Unit II

Part A

Define Object. How do you declare an object in Java?


Mention the characteristics of Constructors?
Write short notes on Garbage Collection.
Explain the uses of ‘this’ keyword with examples.
How do you pass objects as arguments?

Part B

Discuss about various types of constructor with example.


Distinguish Call by value and Call by reference with examples.
Explain about (i) static and final variables (ii) finalize() methods with examples.
Write an explanatory note on Nested and Inner Classes.
List the methods of String class. Explain each method with an example.
Explain in detail about the StringBuffer Class in Java.

Unit III

Part A

Discover different types of exception occur during runtime.


Define inheritance and mention its types
How does java support multiple inheritance?
What is Interface? Describe syntax, feature & need of an interface.
What is Exception? Give different types of exception that could occur during runtime.
Give a note on Dynamic method dispatch

Part B

Examine interface and its implementation with suitable example.


Write a program to input name and age of a person and throw an user-define exception, if the
entered age is negative.
Write in detail about the types of Inheritance and explain the purpose Super keyword in
inheritance
Explain working with Abstract class and Method and Using final with inheritance with
examples
Write in detail how to create a package and explain importing packages with suitable
examples
Explain Interfaces and its implementation in detail with example
Explain the following terms with respect to exception handling:
a. Try/Catch
[Link]
[Link]
[Link]

Unit IV

Part A

Explain synchronization with example.


Explain Thread priorities and inter-thread communication in detail.
What is thread? Differentiate between multiprocessing & multithreading?
What is thread priority? Write the default values? Write methods to get & change priority of
thread.
Write about complete life cycle of thread.
What is synchronization? How do we achieve it?
Give a brief note on StringTokenizer with its constructors

Part B

Write about the following with suitable example (a) Creating a Thread by Extending Thread
Class (b)Creating a Thread by implementing Runnable Interface.
Discuss the following: (1) Explain multiple thread. (2) Write a program to define two
threads. One thread will print 1 to 10 number whereas other will print 10 to 1 numbers.
Explain Thread priorities and inter-thread communication in detail.
Explain vector class in detail with example
Write in detail about stack class.
Explain GregorianCalendar class in detail.

Unit V
Part A

Write a program to copy content of one file to another using character stream class
Write about Event Sources
List the most important event classes and write about AWT Event class in brief.
Write about Understanding Layout Managers
Describe different stream classes.
Give a note on ComponentEvent Class and ContainerEvent Class in brief

Part B

Examine ActionEvent and AdjustmentEvent Classes with constructors and methods in detail.
Define stream and explain the Types of streams with suitable examples
Write about MouseEvent Class in detail with its constructors
Explain Event Listener Interfaces in detail
Explain AWT control fundamentals and explain any 3 controls in detail
Explain (a) InputEventClass (b) ItemEvent Class (c) KeyEvent Class

Overall

What are the different salient features that the Java language provides?
How do you declare and initialize a one-dimensional array in Java, and how do
you access and modify the elements of the array?
What is Object Oriented Programming? Discuss the various OOPs principles in
Java
What is an interface in Java? How does a class implement an interface, and how
does it use the methods defined in the interface?
How do you use the Scanner class in Java to read input from the user, and what
are some of the available methods for parsing and extracting different types of
data (e.g., integers, doubles, strings) from the input stream?
Differentiate between Method Overloading and Overriding in Java
How do you handle events in a Java program using event listeners and event
objects? What are the steps for implementing an event listener interface, and how
do you register an event listener with a component to receive notifications of
events?
What is a constructor in Java, and how do you define and use constructors to
create objects of a class? How do constructors differ from other methods?
Write a program in Java to display student id and name using default and
parameterized constructors.
Discuss the working of 'continue', 'break' and 'return' statements in a Java loop.
Discuss the advantages of incorporating packages in Java
What is Inheritance and explain the terms parent class and child class? State the
advantages of Inheritance in Java
What are some of the common methods for manipulating strings in Java, and
how do you use these methods to perform tasks such as concatenation, searching
and replacing?
Explain the following keywords with context to inheritance in Java - extends and
this
Discuss the differences between checked and unchecked exceptions in Java.
What is Deadlock in Java? What are the precautions to avoid a deadlock state in
Java ?
With regards to event handling, describe the different Layout Managers in Java.
With the help of suitable examples, explain the different kinds of operators in
Java.
With the help of suitable examples, discuss in detail the Java AWT Buttons and
AWT Labels.
Describe in detail the String constructor in Java.
Write a code in java to execute multiple catch [Link] name as
'MultipleCatchBlock' and initialize an array and using array implement
arithmeticexception, array index out of bounds exception and general exception.
Explain in detail the following:
a. life cycle of thread
b. thread and its advantages.
With the help of suitable examples, discuss the various access modifiers in Java.
Difference between Multilevel Inheritance and Hierarchical Inheritance in Java.
Support your answer with suitable code examples.

Common questions

Powered by AI

Java's support for exception handling enhances program robustness by allowing developers to anticipate and manage runtime errors while maintaining normal program flow. Checked exceptions are checked at compile-time and must be declared or handled, ensuring that a method explicitly deals with potential issues. Unchecked exceptions, such as runtime exceptions and errors, are not checked at compile-time, giving developers the flexibility to decide how to handle them. This dual approach ensures that critical errors are addressed while allowing some flexibility in simpler scenarios .

Java's robustness stems from features like automatic garbage collection, exception handling, and strong memory management. Garbage collection helps in reclaiming memory automatically, preventing memory leaks. Exception handling enables structured error management, ensuring that runtime errors are dealt with systematically. Java's strong type-checking at compile-time and runtime helps prevent issues that could lead to program crashes. However, these features come with trade-offs such as increased overhead from garbage collection, which can impact real-time performance, and additional complexity in handling checked exceptions .

Access modifiers in Java are keywords that set the accessibility of classes and members. They include public, private, protected, and default (no modifier). 'Public' allows the class or member to be accessible from any other class. 'Private' restricts the access to within the enclosing class. 'Protected' allows accessibility within subclasses and classes in the same package. The default modifier permits access within classes of the same package. For instance, using 'private' for a field ensures that other classes cannot directly change its value, enforcing encapsulation .

The core object-oriented programming concepts in Java include encapsulation, inheritance, polymorphism, and abstraction. Encapsulation ensures that an object's internal state is hidden from the outside, exposing only what is necessary. Inheritance allows classes to inherit properties and behaviors from other classes, promoting code reuse and a hierarchical class structure. Polymorphism enables a single function or method to operate in different ways based on the object it is acting upon, improving code flexibility. Abstraction simplifies complex systems by modeling classes that capture only relevant data and functions, making the system easier to understand and extend .

Synchronization in Java is implemented using the synchronized keyword, which locks an object or method, allowing only one thread to execute within the synchronized context at any time. This is crucial for preventing thread interference and ensuring atomicity of operations on shared data. Improper synchronization can lead to issues such as race conditions, where the output depends on the sequence or timing of threads execution, or deadlocks, where two or more threads are waiting indefinitely for resources held by each other. Properly synchronizing resources maintains data consistency and prevents such undesirable states in multithreaded applications .

The lifecycle of a thread in Java includes several states: New, Runnable, Blocked, Waiting, Timed Waiting, and Terminated. A thread starts in the New state after instantiation and moves to Runnable when the start() method is called. It transitions to Blocked if it needs to acquire a lock or enters Waiting when waiting for other threads. Timed Waiting occurs during operations with specified waiting times, such as sleep(). Finally, a thread reaches the Terminated state upon completion. Thread priorities, ranging from MIN_PRIORITY (1) to MAX_PRIORITY (10), influence thread scheduling by hinting at the importance of running certain threads over others. While not a guarantee, properly setting priorities can improve performance and resource allocation in multithreaded environments .

Constructors in Java are special methods used to initialize new objects. Unlike regular methods, constructors do not have a return type, not even void, and are named after the class they belong to. They cannot be called directly, as they are invoked implicitly when an object is instantiated with the 'new' keyword. Constructors can be overloaded to initialize objects in different ways through different parameter lists, providing flexibility in object creation .

Dynamic method dispatch in Java is a mechanism by which a call to an overridden method is resolved at runtime rather than compile-time. It is a key aspect of runtime polymorphism, allowing the Java Virtual Machine (JVM) to invoke the correct method version based on the actual object type, not the reference type. For example, if class A defines a method and class B, a subclass, overrides it, calling the method on a B instance through an A reference will execute B's version of the method. This ensures that the most specific method appropriate to the actual object is executed, enhancing flexibility in method handling .

Interfaces in Java define a contract that classes can implement, specifying methods that must be provided. They contain method declarations without implementations, allowing different classes to provide varied behaviors while adhering to the same interface structure. Interfaces are crucial in achieving multiple inheritance in Java, as a class can implement multiple interfaces, thereby overcoming Java's limitation of single inheritance among classes. This allows for more flexible and modular design by integrating diverse functionalities from multiple sources without the conflict of variable or method name clashes .

Deadlock in Java occurs when two or more threads are indefinitely blocked, each waiting for resources held by the others, forming a cycle. Strategies to prevent deadlock include acquiring locks in a consistent order to avoid circular wait, using tryLock() with a timeout instead of block-and-wait, employing deadlock detection tools to identify deadlock-prone sections, and designing programs to minimize the use of locks by rethinking resource access logic and reducing shared data dependencies. Effective design and careful resource management can prevent deadlocks, thus ensuring better concurrency handling .

You might also like