Java_Questions_Answers
Java_Questions_Answers
1. In which memory is a String stored when we create a string using the new operator?
- Heap memory.
3. Which of the following keywords are used to control access to a class Member?
- B) abstract.
- True.
- True.
- B) float average[].
8. Java virtual machine is ______.
- B) Independent.
9. Which method is used to set the graphics' current color to the specified color in the
graphics class?
- setColor(Color c).
- True.
12. What is the length of the application box made by the following Java program?
```java
import java.awt.*;
import java.applet.*;
```
- C) 100.
Group-B: Short Answer Type Questions
- Qualified association refers to a relationship between two classes where one class
attribute.
Example:
In a library system, the relationship between a "Library" and "Book" classes can be
programming.
(functions).
- Difference:
- The `static` keyword is used to create class-level variables and methods that belong
Example:
```java
class Example {
```
Example:
```java
class Parent {
```
- AWT (Abstract Window Toolkit): A Java package used to create GUI components like
- Event Listener: An interface in Java used to handle events like clicks or keypresses.
Example: `ActionListener`.
- final vs finally:
10. Create a package and write Java files for basic arithmetic operations.
11. (a) What are exceptions? Explain user-defined and system-defined exceptions with
examples.
Example:
```java
```