Basic Concepts Of Java

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Anurag_Shrivasta
A
Anurag_Shrivasta
Community Contributor
Quizzes Created: 1 | Total Attempts: 234
Questions: 12 | Attempts: 234

SettingsSettingsSettings
Java Quizzes & Trivia

Java is one of the programming languages that every programmer must be conversant with. Most applications and websites will not work unless java is installed therefore increasing the need to understand its application and use. Take up the quiz below and see how well you understand some basic concepts of java.


Questions and Answers
  • 1. 

    'this' keyword is basically used for ?

    • A.

      Differentiate the local variable and global variable

    • B.

      Differentiate the function

    • C.

      Not available

    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.

    Rate this question:

  • 2. 

    Is Java is a portable language ?

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 3. 

    Is finally block is executed in any condition when our program generate any error or not ?

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 4. 

    How many parameters for Oval shape in Applet ?

    • A.

      2

    • B.

      6

    • C.

      4

    • D.

      1

    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.

    Rate this question:

  • 5. 

    Import.java.awt.*; what it is ?

    • A.

      Function

    • B.

      Predefined Package

    • C.

      Interface

    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".

    Rate this question:

  • 6. 

    How many types of Exception  handling ?

    • A.

      Four

    • B.

      Two

    • C.

      One

    • D.

      Five

    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.

    Rate this question:

  • 7. 

    Init method is the part of ?

    • A.

      Package

    • B.

      Exception handling

    • C.

      Applet

    • D.

      Constructor

    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.

    Rate this question:

  • 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?

    • A.

      ArrayIndexOutOfBoundsException

    • B.

      NumberFormateException

    • C.

      ArithmeticException

    • D.

      No error

    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.

    Rate this question:

  • 9. 

    Swing is ____________ type of program ?

    • A.

      Light weighted

    • B.

      Heavy Weighted

    • C.

      None of above

    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.

    Rate this question:

  • 10. 

    How many functions are in Applet life cycle ?

    • A.

      2

    • B.

      6

    • C.

      3

    • D.

      5

    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.

    Rate this question:

  • 11. 

    Grid layout is based on ?

    • A.

      Rows

    • B.

      Columns

    • C.

      A and B

    • D.

      None of above

    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.

    Rate this question:

  • 12. 

    Full form of JDBC?

    • A.

      Java Data base consistency

    • B.

      Java Data base communication

    • C.

      Java Data base correcive

    • D.

      Java Database Connectivity

    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.

    Rate this question:

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.