What is an applet?
An applet is a small Java program that can be embedded in a web page and run inside a web browser. Applets are
used to add interactive features and animations to web pages.
Name one tag which does not require any terminator?
The <br> tag is the only HTML tag that does not require a terminator. It is used to insert a line break into a text block.
Which class in Java is super class of every other class?
The Object class is the superclass of every other class in Java. This means that every class in Java,
either directly or indirectly, inherits from the Object class.
What is an interface?
An interface is a blueprint for a class. It defines the methods that a class must implement, but it
does not provide any implementation for those methods. The implementation of the methods is
left to the class that implements the interface.
What is remote applet?
A remote applet is an applet that is stored and executed on a remote server. It is downloaded to the user's
computer and executed when the user visits the web page that contains the applet.
Remote applets are typically used to provide interactive features and animations to web pages that are too
complex or computationally expensive to be implemented using HTML and JavaScript.
What is serialization?
Serialization is the process of converting an object into a stream of bytes. This stream of bytes
can then be stored in a file, transmitted over a network, or persisted to a database.
What function is called to display the output of an applet?
The paint() method in the Applet class is called to display the output of an applet.The paint() method is
called by the browser whenever the applet needs to be repainted. The paint() method takes a Graphics
object as a parameter. The Graphics object provides methods for drawing shapes, lines, text, and images.
The applet can use the Graphics object to draw its output on the web page.
What will be the output of the following statements?
System.out.println(“Hi there”);
System.out.println(“This is my Exam”);
Hi there
This is my Exam
What are the tasks of JVM?
The Java Virtual Machine (JVM) is a software program that executes Java bytecode. It is responsible for
loading, verifying, executing, and garbage collecting Java bytecode.
The main tasks of the JVM are:
• Loading: The JVM loads the Java bytecode from a class file into memory.
• Verification: The JVM verifies the Java bytecode to ensure that it is valid and does not contain any
security vulnerabilities.
• Execution: The JVM executes the Java bytecode by converting it into machine code that can be
executed by the underlying hardware.
• Garbage collection: The JVM automatically manages the memory used by Java objects. When a Java
object is no longer needed, the JVM garbage collector automatically reclaim the memory used by the
object.
Can we access both super class and sub class members if we create an object or sub class?
Yes, we can access both superclass and subclass members if we create an object of the subclass.
This is because the subclass inherits all of the public and protected members of its superclass.
Distinguish between the terms: Inheritance and Polymorphism.
Describe different forms of inheritance with examples.
There are four main forms of inheritance in Java:
• Single inheritance: A class can only inherit from one superclass.
• Multilevel inheritance: A class can inherit from a superclass, and the superclass can
inherit from another superclass, and so on.
• Multiple inheritance: A class can inherit from multiple superclasses.
• Hybrid inheritance: A combination of single, multilevel, and multiple inheritance.
What is the difference between Exception and Error? Show with an examples.
Exception is an event that occurs during the execution of a program that disrupts the normal flow of the program's
instructions. Exceptions can be caused by a variety of factors, such as:
• Input errors (e.g., trying to read from an empty file)
• Arithmetic errors (e.g., dividing by zero)
• Resource exhaustion (e.g., running out of memory)
• Software defects (e.g., a bug in the program code)
Exceptions are typically handled by the program itself, using a try-catch block. A try-catch block allows the program
to catch and handle exceptions gracefully, without crashing.
Error is a serious problem that occurs during the execution of a program that cannot be recovered from. Errors are
typically caused by factors outside of the program's control, such as:
• Hardware failure (e.g., a disk drive failure)
• Operating system failure (e.g., a power outage)
• Software defects (e.g., a bug in the operating system code)
Errors are typically not handled by the program itself, and they will usually cause the program to crash.
Write program to handle different types of exception using multiple catch statement.
Compare and contrast overloading and overriding methods.
What is inheritance and how does it help us create new classes quickly?
Inheritance is a programming concept that allows a class to inherit the properties and behaviors of another class. The
class that inherits is called the subclass, and the class that is inherited from is called the superclass.Inheritance can
help us create new classes quickly by allowing us to reuse code that has already been written
Here are some of the benefits of using inheritance:
• Code reuse: Inheritance allows us to reuse code that has already been written. This can save us time
and effort, and it can also help to improve the quality of our code.
• Maintainability: Inheritance can make our code more maintainable. This is because changes to the
superclass will be automatically reflected in all of the subclasses.
• Polymorphism: Inheritance is one of the key concepts that enables polymorphism. Polymorphism is
the ability of an object to take on different forms. This can make our code more flexible and
reusable.
List the basic data types used in Java. Give examples
Write a Java program to determine the sum of the following harmonic series for a given value of n:
1+1/2+1/3+…….+1/n.