1.
'this' keyword is basically used for ?
Correct Answer
A. Differentiate the local variable and global variable
Explanation
The correct answer is "Differentiate the local variable and global variable." The 'this' keyword is not used for differentiating between local and global variables. Instead, it is used to refer to the current instance of a class. Local variables are declared within a specific block or method and have a limited scope, while global variables are declared outside any method or block and can be accessed throughout the program.
2.
Is Java is a portable language ?
Correct Answer
A. True
Explanation
Java is considered a portable language because it can run on different operating systems and hardware platforms without the need for major modifications. This portability is achieved through the Java Virtual Machine (JVM), which allows Java programs to be executed on any system that has a compatible JVM installed. The JVM acts as an intermediary between the Java code and the underlying hardware, providing a consistent runtime environment for Java applications. This makes it easier for developers to write code that can be deployed and run on multiple platforms, making Java a highly portable language.
3.
Is finally block is executed in any condition when our program generate any error or not ?
Correct Answer
A. True
Explanation
The finally block is always executed, regardless of whether our program generates an error or not. It is used to perform cleanup actions or release resources that were acquired in the try block. This ensures that important tasks are executed even if an exception occurs.
4.
How many parameters for Oval shape in Applet ?
Correct Answer
C. 4
Explanation
The Oval shape in Applet requires 4 parameters. These parameters define the position and size of the oval. The first two parameters specify the coordinates of the top-left corner of the bounding rectangle, while the last two parameters determine the width and height of the oval. By specifying these parameters, the oval can be accurately positioned and sized within the applet.
5.
Import.java.awt.*; what it is ?
Correct Answer
B. Predefined Package
Explanation
The statement "import.java.awt.*;" is indicating the use of a predefined package. In Java, packages are used to organize and group related classes and interfaces. The "java.awt" package is a predefined package in Java that contains classes and interfaces for creating graphical user interfaces (GUI). The "import" keyword is used to make classes and interfaces from a package accessible in the current program. Therefore, the correct answer is "Predefined Package".
6.
How many types of Exception handling ?
Correct Answer
B. Two
Explanation
There are two types of exception handling: checked exceptions and unchecked exceptions. Checked exceptions are the exceptions that are checked at compile-time, and the programmer is required to handle these exceptions by either catching them or declaring them in the method signature. Unchecked exceptions, on the other hand, are not checked at compile-time and do not require explicit handling. They are typically runtime exceptions that occur due to programming errors or unexpected conditions.
7.
Init method is the part of ?
Correct Answer
C. Applet
Explanation
The init method is a part of an applet. In Java, an applet is a small program that runs within a web browser. The init method is a special method that is automatically called when the applet is first created. It is used to initialize the applet and perform any necessary setup tasks. Therefore, the correct answer is applet.
8.
class A
{
public static void main (String args[])
{
int a;
a=5/0;
System.out.println("Value of a "+a);
}
}
what type of error it generated?
Correct Answer
C. ArithmeticException
Explanation
The given code is generating an ArithmeticException. This is because the code is trying to divide the number 5 by 0, which is not possible in mathematics and results in an arithmetic error.
9.
Swing is ____________ type of program ?
Correct Answer
A. Light weighted
Explanation
Swing is considered a light-weighted type of program. This is because Swing is a part of the Java Foundation Classes (JFC) and is built on top of the Abstract Window Toolkit (AWT). Unlike AWT, Swing does not rely on the underlying operating system's GUI components, which makes it platform-independent and allows for a more consistent and customizable look and feel across different operating systems. Additionally, Swing provides a rich set of GUI components and supports various features like event handling, layout managers, and graphics rendering, making it suitable for developing graphical user interfaces for Java applications.
10.
How many functions are in Applet life cycle ?
Correct Answer
D. 5
Explanation
The correct answer is 5. In the Applet life cycle, there are five functions that are automatically called by the applet container. These functions are init(), start(), stop(), destroy(), and paint(). The init() function is called when the applet is initialized, start() is called when the applet is started or restarted, stop() is called when the applet is stopped or suspended, destroy() is called when the applet is destroyed, and paint() is called whenever the applet needs to be redrawn.
11.
Grid layout is based on ?
Correct Answer
C. A and B
Explanation
The grid layout is based on both rows and columns. In a grid layout, elements are arranged in a grid-like structure, with rows and columns forming the framework. This allows for a flexible and organized arrangement of content on a webpage or application. The rows define the horizontal placement of elements, while the columns define the vertical placement. By using a combination of rows and columns, developers can create responsive and visually appealing designs that adapt to different screen sizes and devices.
12.
Full form of JDBC?
Correct Answer
D. Java Database Connectivity
Explanation
JDBC stands for Java Database Connectivity. It is a Java API that allows Java programs to interact with databases. It provides a set of classes and methods for connecting to a database, executing SQL statements, and retrieving and manipulating data. JDBC is widely used in Java applications for database access and is supported by most database vendors.