Java Exam The Best

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 Man04
M
Man04
Community Contributor
Quizzes Created: 14 | Total Attempts: 6,156
Questions: 10 | Attempts: 82

SettingsSettingsSettings
Java Exam The Best - Quiz


i love java the best broother


Questions and Answers
  • 1. 

    What is the file extension of a java source program ?

    • A.

      Class

    • B.

      Obj

    • C.

      Java

    • D.

      Bin

    Correct Answer
    C. Java
    Explanation
    The file extension of a Java source program is "java". This is because Java source code files are typically saved with a .java extension. This allows the Java compiler and other tools to recognize and process the file as a Java source code file.

    Rate this question:

  • 2. 

    You can recognise a constructor of a class because:

    • A.

      It has the same name as the class and no return type

    • B.

      It has the same name as the class and a void return type

    • C.

      It has the same name as the class and an int return type

    • D.

      It has an extended name from the class and no return type

    Correct Answer
    A. It has the same name as the class and no return type
    Explanation
    A constructor is a special method in a class that is used to initialize objects of that class. It has the same name as the class and no return type because its purpose is to create and initialize an instance of the class, rather than returning a value. This allows the constructor to be called automatically when an object is created, using the new keyword.

    Rate this question:

  • 3. 

    The primary function of a constructor is to

    • A.

      Put a class together on the stack and return a pointer to itself

    • B.

      Contruct all the code that a class can execute and return void

    • C.

      Make a memory copy of a class and return a pointer to that instance

    • D.

      Respond to the user that the class is ready to use no pointers involved

    Correct Answer
    C. Make a memory copy of a class and return a pointer to that instance
    Explanation
    The given answer is incorrect. The primary function of a constructor is to initialize the object of a class. It is responsible for setting the initial state of the object and allocating memory for it. Constructors do not make a memory copy of a class and return a pointer to that instance.

    Rate this question:

  • 4. 

    The place where classes are stored and manipulated is called a

    • A.

      Pile

    • B.

      Stack

    • C.

      Store

    • D.

      Heap

    Correct Answer
    D. Heap
    Explanation
    A heap is a data structure that stores and organizes data in a specific way. In computer programming, a heap is a region of memory used for dynamic memory allocation. It is a region of memory where objects are stored and manipulated. Unlike a stack, which is a specific type of data structure that follows the Last In First Out (LIFO) principle, a heap does not have a specific order for accessing or removing elements. Instead, it allows for efficient allocation and deallocation of memory at runtime. Therefore, the correct answer is heap.

    Rate this question:

  • 5. 

    A constructor is called with the keyword

    • A.

      new

    • B.

      Old

    • C.

      This

    • D.

      There

    Correct Answer
    A. new
    Explanation
    The correct answer is "new". In object-oriented programming, the "new" keyword is used to create an instance of a class and call its constructor. The constructor is a special method that is automatically invoked when an object is created. It initializes the object's state and performs any necessary setup. Therefore, when we want to create a new object, we use the "new" keyword to call its constructor.

    Rate this question:

  • 6. 

    How many constructors can a class have ?

    • A.

      None but the system will provide one

    • B.

      As many as required

    • C.

      Only one

    • D.

      Only two

    Correct Answer
    B. As many as required
    Explanation
    A class can have as many constructors as required. Constructors are special methods used to initialize objects of a class. Different constructors can be created with different parameters to allow for various ways of initializing objects. Therefore, the number of constructors a class can have depends on the specific requirements and needs of the program or application being developed.

    Rate this question:

  • 7. 

    Whta is the access scope of a variable declared inside a method block

    • A.

      The whole java class that method is in

    • B.

      Only from within that method

    • C.

      The whole java file that method is in

    • D.

      From any other java file.

    Correct Answer
    B. Only from within that method
    Explanation
    The access scope of a variable declared inside a method block is limited to only within that method. This means that the variable cannot be accessed or used outside of the method block. It is local to the method and can only be used within the method's code block. Other methods or classes within the same file or different files cannot access this variable.

    Rate this question:

  • 8. 

    What is the first line of the first method executed in a java application:

    • A.

      Public void main (String args) {

    • B.

      Public static void main ( String args) {

    • C.

      Public static main (String args) {

    • D.

      Static void main (String args {

    Correct Answer
    B. Public static void main ( String args) {
    Explanation
    The correct answer is "public static void main ( String args) {". This is the correct first line of the first method executed in a Java application because the main method is the entry point of a Java program and it must be declared with the "public" and "static" keywords. The method name is "main" and it takes a String array as its argument named "args".

    Rate this question:

  • 9. 

    Java swing windows applications generally extend JFrame because

    • A.

      JFrame is a bigger class than JPanel

    • B.

      JFrame cannot be extended so we never use it

    • C.

      JFrame put a frame around a DOS window

    • D.

      The language developers have already prepared JFrame with many useful methods

    Correct Answer
    D. The language developers have already prepared JFrame with many useful methods
    Explanation
    Java swing windows applications generally extend JFrame because the language developers have already prepared JFrame with many useful methods. This allows developers to easily add functionality and customize the window application according to their needs. JFrame provides methods for managing the window, handling events, and adding components to the user interface. By extending JFrame, developers can take advantage of these pre-existing methods and save time and effort in implementing common window functionalities.

    Rate this question:

  • 10. 

    How many bits does an int primitive variable have ?

    • A.

      64

    • B.

      32

    • C.

      16

    • D.

      8

    Correct Answer
    B. 32
    Explanation
    An int primitive variable in most programming languages, including Java, has a size of 32 bits. This means it can store values ranging from -2,147,483,648 to 2,147,483,647. The size of an int variable is fixed and does not change regardless of the platform or system it is being used on.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Sep 12, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jun 04, 2010
    Quiz Created by
    Man04
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.