Code Execution Championship -round-1- 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 Catherine Halcomb
C
Catherine Halcomb
Community Contributor
Quizzes Created: 1428 | Total Attempts: 5,929,496
Questions: 41 | Attempts: 502

SettingsSettingsSettings
Java Quizzes & Trivia

Pls Note:
1) There are 20 questions in a quiz.
2) Time duration is 15 minutes.
3) Only one attempt is allowed.
4) Candidate can navigate questions and review answers before final submission
5) Compulsory to fill all the mentioned details.
6) Kindly provide the correct details.


Questions and Answers
  • 1. 

    From the following statements which is a disadvantage of an java array?

    • A.

      An array can hold primitive types data

    • B.

      . An array has its size that is known as array length

    • C.

      An array knows only its type that it contains. Array type is checked at the compile-time

    • D.

      An array holds only one type of data

    Correct Answer
    D. An array holds only one type of data
    Explanation
    An array holds only one type of data, which is a disadvantage because it restricts the flexibility of storing different types of data within the same array. This means that if we want to store multiple types of data, we would need to create separate arrays for each type, which can be cumbersome and inefficient.

    Rate this question:

  • 2. 

    Which method returns the interrupted flag after that it sets the flag to false if it is true?

    • A.

      IsInterrupted()

    • B.

      Static interrupted()

    • C.

      Non static interrupted()

    • D.

      Both A & C

    Correct Answer
    B. Static interrupted()
    Explanation
    The correct answer is "static interrupted()". This method returns the interrupted flag and then sets it to false if it is true. This method is a static method, meaning it can be called directly on the Thread class without needing an instance of the Thread object. The "isInterrupted()" method also returns the interrupted flag, but it does not reset the flag to false. Therefore, the correct answer is "static interrupted()".

    Rate this question:

  • 3. 

    Abbreviate the term POJO?

    • A.

      Plain Old Java Object

    • B.

      Performance Old Java Object

    • C.

      Performance Optimize Java Object

    • D.

      None of the above

    Correct Answer
    A. Plain Old Java Object
    Explanation
    The term POJO stands for Plain Old Java Object. It refers to a Java object that is simple, without any special frameworks or dependencies. A POJO is a basic Java class that follows certain conventions and does not require any specific interfaces or base classes. It is used to represent data in a straightforward manner, making it easier to understand and maintain.

    Rate this question:

  • 4. 

    The following two rules are defined by? 1. The parameters may differ in their type or number, or in both. 2. They may have the same or different return types.

    • A.

      Method overloading

    • B.

      Method overriding

    • C.

      Constructor overloading

    • D.

      None of the above

    Correct Answer
    A. Method overloading
    Explanation
    The given rules state that parameters in a method can differ in type or number, and they can also have the same or different return types. This is a characteristic of method overloading, where multiple methods with the same name but different parameters are defined in a class. Therefore, the correct answer is method overloading.

    Rate this question:

  • 5. 

    Which allows you to migrate your implementations over time without breaking the code that depends on the public interface of your classes?

    • A.

      Polymorphism

    • B.

      Inheritance

    • C.

      Encapsulation

    • D.

      Both A & B

    Correct Answer
    C. Encapsulation
    Explanation
    Encapsulation allows you to migrate your implementations over time without breaking the code that depends on the public interface of your classes. This is because encapsulation hides the internal details of an object and only exposes a public interface, which can be accessed by other objects. By keeping the public interface consistent while making changes to the internal implementation, encapsulation ensures that the code depending on the public interface remains unaffected. Therefore, encapsulation is the correct answer for this question.

    Rate this question:

  • 6. 

    Which is used for writing data to a file in file handling?

    • A.

      FileInputStream

    • B.

      FileOutputStream

    • C.

      Both A & B

    • D.

      None of the above

    Correct Answer
    B. FileOutputStream
    Explanation
    FileOutputStream is used for writing data to a file in file handling. FileInputStream, on the other hand, is used for reading data from a file. Therefore, the correct answer is FileOutputStream.

    Rate this question:

  • 7. 

    In which state is the thread after invocation of start() method, but the thread Scheduler has not selected it to be the running thread?

    • A.

      Running

    • B.

      Runnable

    • C.

      Terminated

    • D.

      Non-Runnable

    Correct Answer
    B. Runnable
    Explanation
    After the invocation of the start() method, the thread enters the Runnable state. In this state, the thread is ready to be scheduled and executed by the thread scheduler. However, the thread scheduler has not yet selected it to be the running thread. Therefore, the correct answer is Runnable.

    Rate this question:

  • 8. 

    Which package is used for analyzing code during run time?

    • A.

      java.lang.reflect

    • B.

      Java.awt

    • C.

      Java.io

    • D.

      Java.applet

    Correct Answer
    A. java.lang.reflect
    Explanation
    The package java.lang.reflect is used for analyzing code during run time. This package provides classes and interfaces that allow programmatic access to information about the classes, methods, and fields of loaded classes. It provides the ability to inspect and modify the runtime behavior of applications. The other packages mentioned (java.awt, java.io, java.applet) do not specifically deal with analyzing code during run time.

    Rate this question:

  • 9. 

    Which mechanism is provided to handle the runtime errors so that normal flow of the application can be maintained?

    • A.

      Exception Handling

    • B.

      String Handling

    • C.

      Event Handling

    • D.

      None of the above

    Correct Answer
    A. Exception Handling
    Explanation
    Exception handling is the mechanism provided to handle runtime errors in a program. It allows the program to catch and handle exceptions, preventing them from causing the program to crash. By using try-catch blocks, the program can gracefully handle exceptions and continue with its normal flow. This ensures that the application can maintain its expected behavior even when unexpected errors occur.

    Rate this question:

  • 10. 

    Which driver uses ODBC driver to connect to the database?

    • A.

      JDBC-ODBC bridge driver

    • B.

      Native - API driver

    • C.

      Network Protocol driver

    • D.

      Thin driver

    Correct Answer
    A. JDBC-ODBC bridge driver
    Explanation
    The JDBC-ODBC bridge driver uses the ODBC driver to connect to the database. The JDBC-ODBC bridge is a Java library that allows Java applications to access databases through the ODBC interface. It acts as a bridge between the Java application and the ODBC driver, enabling the Java application to communicate with the database using the ODBC protocol. This driver is commonly used when there is a need to connect a Java application to a database that only has an ODBC driver available.

    Rate this question:

  • 11. 

    Which is invoked after the init() method or browser is maximized?

    • A.

      Public void start()

    • B.

      Public void paint(Graphics g)

    • C.

      Public void stop()

    • D.

      Public void init()

    Correct Answer
    A. Public void start()
    Explanation
    The method public void start() is invoked after the init() method or when the browser is maximized. This method is part of the applet lifecycle and is called automatically by the browser when the applet is started or when it needs to be restarted. It is commonly used to start any thread or animation in the applet, or to resume any paused activity.

    Rate this question:

  • 12. 

    Which class provides many methods for graphics programming?

    • A.

      Java.awt

    • B.

      java.Graphics

    • C.

      Java.awt.Graphics

    • D.

      None of the above

    Correct Answer
    C. Java.awt.Graphics
    Explanation
    The correct answer is java.awt.Graphics. This class provides many methods for graphics programming in Java. It is a part of the java.awt package, which stands for Abstract Window Toolkit. The java.awt.Graphics class allows developers to draw and manipulate graphics objects, such as lines, shapes, and text, on a graphical user interface. It provides methods for drawing and filling shapes, setting colors and fonts, and transforming coordinates, among other functionalities.

    Rate this question:

  • 13. 

    Which statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression?

    • A.

      If

    • B.

      Switch

    • C.

      Nested-if

    • D.

      If-else-if

    Correct Answer
    B. Switch
    Explanation
    The switch statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression. It allows you to specify multiple cases, each representing a different possible value of the expression. When the expression matches a particular case, the corresponding block of code is executed. This is particularly useful when you have a large number of possible values and you want to avoid writing multiple if-else statements. The switch statement improves code readability and makes it easier to understand the logic of the program.

    Rate this question:

  • 14. 

    Which field of StreamTokenizer if the token is a word, this filed contains the word that can be used in programming?

    • A.

      String sval

    • B.

      Double nval

    • C.

      Int ttype

    • D.

      Static final int TT_WORD

    Correct Answer
    B. Double nval
  • 15. 

    Which method of string class in java is used to convert the boolean into String?

    • A.

      Public static String valueOf(double I)

    • B.

      Public static String valueOf(boolean I)

    • C.

      public boolean equals(Object anObject)

    • D.

      Public static String valueOf(Object obj)

    Correct Answer
    A. Public static String valueOf(double I)
    Explanation
    The correct answer is "public static String valueOf(boolean I)". This method is used to convert a boolean value into a String. It takes a boolean parameter and returns a String representation of that boolean value.

    Rate this question:

  • 16. 

    Which Exception occurs when a class is not found while dynamically loading a class using the class loaders?

    • A.

      ClassNotFoundException

    • B.

      ClassFoundException

    • C.

      NoClassDefFoundError

    • D.

      ClassDefFoundError

    Correct Answer
    A. ClassNotFoundException
    Explanation
    The correct answer is ClassNotFoundException. This exception occurs when a class is not found while dynamically loading a class using the class loaders.

    Rate this question:

  • 17. 

    Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?

    • A.

      JDBC-Net

    • B.

      JDBC-ODBC bridge

    • C.

      Native API as basis

    • D.

      Native protocol as basis

    Correct Answer
    A. JDBC-Net
    Explanation
    JDBC-Net is the correct answer because it refers to the driver network connection that is indirect and made by a JDBC client to a middleware process acting as a bridge to the DBMS server. This indicates that the JDBC-Net driver allows the client to connect to the DBMS server through a middleware process, providing a layer of abstraction between the client and the server.

    Rate this question:

  • 18. 

    Which Indicates a result set that cannot be updated programmatically in concurrency?

    • A.

      CONCUR_UPDATABLE

    • B.

      CONCUR_READ_ONLY

    • C.

      All of the above

    • D.

      None of the above

    Correct Answer
    B. CONCUR_READ_ONLY
    Explanation
    The correct answer is CONCUR_READ_ONLY because it indicates that the result set cannot be updated programmatically in concurrency. This means that any attempt to modify the data in the result set will result in an error. CONCUR_UPDATABLE, on the other hand, allows for programmatically updating the result set. "All of the above" and "None of the above" are not correct because they do not specifically address the ability to update the result set programmatically in concurrency.

    Rate this question:

  • 19. 

    Which of the following is true about inheritance in Java? I) Private methods are final. II) Protected members are accessible within a package and inherited classes outside the package. III) Protected methods are final. IV) We cannot override private methods.

    • A.

      1, 2 and 4

    • B.

      1 and 2

    • C.

      1, 2 and 3

    • D.

      2, 3 and 4

    Correct Answer
    A. 1, 2 and 4
    Explanation
    In Java, private methods are not inherited and therefore cannot be overridden. Protected members are accessible within the same package and can also be inherited by classes outside the package. This makes statements I and II true. However, protected methods are not final, so statement III is false. Therefore, the correct answer is 1, 2, and 4.

    Rate this question:

  • 20. 

    What is the range of data type byte in Java?

    • A.

      -128 to 127

    • B.

      -32768 to 32767

    • C.

      -2147483648 to 2147483647

    • D.

      None of the mentioned

    Correct Answer
    A. -128 to 127
    Explanation
    The range of the data type byte in Java is from -128 to 127. This means that a byte variable can hold integer values within this range, including both positive and negative numbers.

    Rate this question:

  • 21. 

    Which data type value is returned by all transcendental math functions?

    • A.

      Int

    • B.

      Float

    • C.

      Double

    • D.

      Long

    Correct Answer
    C. Double
    Explanation
    Transcendental math functions such as sine, cosine, and logarithm involve complex calculations that often result in decimal values. The data type "double" is used to represent floating-point numbers with a higher precision compared to "float". Therefore, it is the most suitable data type to return the accurate and precise results of transcendental math functions.

    Rate this question:

  • 22. 

    Which of the following can be operands of arithmetic operators?

    • A.

      Numeric

    • B.

      Boolean

    • C.

      Characters

    • D.

      Both Boolean & Characters

    Correct Answer
    D. Both Boolean & Characters
    Explanation
    Arithmetic operators can be used with numeric operands to perform mathematical calculations. However, in some programming languages, such as Java, arithmetic operators can also be used with characters and boolean values. When used with characters, arithmetic operators can perform operations such as addition and subtraction based on the ASCII values of the characters. When used with boolean values, arithmetic operators can treat true as 1 and false as 0, allowing for calculations based on boolean logic. Therefore, both boolean and characters can be operands of arithmetic operators.

    Rate this question:

  • 23. 

    Modulus operator, %, can be applied to which of these?

    • A.

      Integers

    • B.

      Floating – point numbers

    • C.

      Both Integers and floating – point numbers.

    • D.

      None of the mentioned

    Correct Answer
    C. Both Integers and floating – point numbers.
    Explanation
    The modulus operator, %, can be applied to both integers and floating-point numbers. It returns the remainder of a division operation. This means that it can be used to determine if a number is even or odd, or to perform cyclic calculations. It is commonly used in programming languages to perform operations involving remainders.

    Rate this question:

  • 24. 

    Decrement operator, –, decreases value of variable by what number?

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    A. 1
    Explanation
    The decrement operator, -, decreases the value of a variable by 1.

    Rate this question:

  • 25. 

    Which of these methods can be used to output a string in an applet?

    • A.

      Display()

    • B.

      Print()

    • C.

      DrawString()

    • D.

      Transient()

    Correct Answer
    C. DrawString()
    Explanation
    The drawString() method can be used to output a string in an applet. This method is specifically designed to draw text on the screen. It takes parameters like the string to be displayed, the x and y coordinates of the starting position, and the font style and size. By using this method, developers can easily display text in an applet and customize its appearance according to their requirements.

    Rate this question:

  • 26. 

    Which of these methods is a part of Abstract Window Toolkit (AWT) ?

    • A.

      Display()

    • B.

      Paint()

    • C.

      DrawString()

    • D.

      Transient()

    Correct Answer
    B. Paint()
    Explanation
    The method "paint()" is a part of the Abstract Window Toolkit (AWT). This method is used to paint the graphics on a component. It is called automatically by the system when a component needs to be repainted, such as when it is first displayed or when it is resized. The paint() method allows developers to customize the appearance of components by implementing their own painting logic.

    Rate this question:

  • 27. 

    Which of these is an incorrect array declaration?

    • A.

      Int arr[] = new int[5]

    • B.

      Int [] arr = new int[5]

    • C.

      Int arr[] arr = new int[5]

    • D.

      int arr[] = int [5] new

    Correct Answer
    D. int arr[] = int [5] new
  • 28. 

    Which of these is an incorrect Statement?

    • A.

      It is necessary to use new operator to initialize an array.

    • B.

      Array can be initialized using comma separated expressions surrounded by curly braces.

    • C.

      Array can be initialized when they are declared.

    • D.

      None of the mentioned

    Correct Answer
    A. It is necessary to use new operator to initialize an array.
    Explanation
    The correct answer is "It is necessary to use new operator to initialize an array." This statement is incorrect because arrays can be initialized without using the new operator. Arrays can be initialized using comma separated expressions surrounded by curly braces, and they can also be initialized when they are declared. Therefore, the correct answer is that none of the statements are incorrect.

    Rate this question:

  • 29. 

    Which of these classes is not part of Java’s collection framework?

    • A.

      Maps

    • B.

      Array

    • C.

      Stack

    • D.

      Queue

    Correct Answer
    D. Queue
    Explanation
    The correct answer is Queue. Queue is not part of Java's collection framework. Java's collection framework includes classes like Maps, Array, and Stack, but Queue is not included. Queue is a separate interface in Java that represents a collection of elements in a specific order. It is used for implementing FIFO (First-In-First-Out) data structures.

    Rate this question:

  • 30. 

    What is Collection in Java?

    • A.

      A group of objects

    • B.

      A group of classes

    • C.

      A group of interfaces

    • D.

      None of the mentioned

    Correct Answer
    A. A group of objects
    Explanation
    A collection in Java refers to a group of objects. It is a data structure that allows storing and manipulating multiple objects as a single unit. Collections provide various methods and operations to add, remove, and retrieve objects efficiently. They are used to organize and manage data in a flexible and dynamic manner. Examples of collections in Java include ArrayList, LinkedList, and HashSet.

    Rate this question:

  • 31. 

    Which of these keywords is not a part of exception handling?

    • A.

      try

    • B.

      Finally

    • C.

      Thrown

    • D.

      Catch

    Correct Answer
    C. Thrown
    Explanation
    The keyword "thrown" is not a part of exception handling. The other three keywords, "try," "finally," and "catch," are used in exception handling to handle and manage exceptions that occur during the execution of a program. The keyword "thrown" is not a valid keyword in exception handling and is not used for any exception-related tasks.

    Rate this question:

  • 32. 

    Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

    • A.

      try

    • B.

      Finally

    • C.

      Throw

    • D.

      Catch

    Correct Answer
    D. Catch
    Explanation
    The keyword "catch" must be used to handle the exception thrown by the try block in a rational manner. The catch block allows programmers to specify the actions or code that should be executed when a specific type of exception is thrown. It provides a way to catch and handle exceptions, preventing the program from abruptly terminating and allowing for error handling and recovery.

    Rate this question:

  • 33. 

    . Which of these is used to perform all input & output operations in Java?

    • A.

      Streams

    • B.

      Variables

    • C.

      classes

    • D.

      Methods

    Correct Answer
    A. Streams
    Explanation
    Streams are used to perform all input and output operations in Java. They provide a convenient way to handle input and output operations by abstracting the underlying details. Streams can be used to read data from a source or write data to a destination, such as files, network connections, or even the console. They allow for efficient and flexible handling of input and output, making them an essential part of Java programming.

    Rate this question:

  • 34. 

    . What does AWT stands for?

    • A.

      All Window Tools

    • B.

      All Writing Tools

    • C.

      Abstract Window Toolkit

    • D.

      Abstract Writing Toolkit

    Correct Answer
    C. Abstract Window Toolkit
    Explanation
    AWT stands for Abstract Window Toolkit. AWT is a set of Java libraries that provides a platform-independent way to create graphical user interfaces (GUIs). It includes a collection of classes and methods that allow developers to create windows, buttons, menus, and other GUI components. AWT is an integral part of the Java Foundation Classes (JFC), which provides a more advanced and flexible GUI framework for Java applications.

    Rate this question:

  • 35. 

    Which of these is a type of stream in Java?

    • A.

      Integer stream

    • B.

      Short stream

    • C.

      Byte stream

    • D.

      Long stream

    Correct Answer
    C. Byte stream
    Explanation
    In Java, a byte stream is a type of stream that is used to read and write data in the form of bytes. It is commonly used for handling binary data or for reading and writing files byte by byte. Byte streams are useful when dealing with low-level I/O operations and when working with data that is represented as individual bytes.

    Rate this question:

  • 36. 

    Which of the following is correct way of implementing an interface salary by class manager?

    • A.

      Class manager extends salary {}

    • B.

      Class manager implements salary {}

    • C.

      Class manager imports salary {}

    • D.

      None of the mentioned.

    Correct Answer
    B. Class manager implements salary {}
    Explanation
    The correct way of implementing an interface in a class is by using the "implements" keyword. Therefore, the correct answer is "class manager implements salary {}". This indicates that the class manager will implement the methods defined in the salary interface.

    Rate this question:

  • 37. 

    Which of these is a mechanism for naming and visibility control of a class and its content?

    • A.

      Object

    • B.

      Packages

    • C.

      Interfaces

    • D.

      None of the Mentioned.

    Correct Answer
    B. Packages
    Explanation
    Packages are a mechanism for naming and visibility control of a class and its content. They provide a way to organize and group related classes, interfaces, and other resources together. By using packages, we can avoid naming conflicts and control the visibility of classes and their members. Packages also facilitate modular programming and code reusability by allowing us to import and use classes from other packages.

    Rate this question:

  • 38. 

    Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?

    • A.

      Public

    • B.

      Protected

    • C.

      No Modifier

    • D.

      All of the mentioned

    Correct Answer
    D. All of the mentioned
    Explanation
    All of the mentioned access specifies (public, protected, and no modifier) can be used for a class so that its members can be accessed by a different class in the same package. The public access specifies allows the class and its members to be accessed by any class in the same package. The protected access specifies allows the class and its members to be accessed by any subclass in the same package. The no modifier (also known as default or package-private) allows the class and its members to be accessed by any class in the same package. Therefore, all of these access specifies can be used to achieve the desired result.

    Rate this question:

  • 39. 

    . Which of these access specifiers can be used for a class so that it’s members can be accessed by a different class in the different package?

    • A.

      Public

    • B.

      Protected

    • C.

      Private

    • D.

      No Modifier

    Correct Answer
    A. Public
    Explanation
    The public access specifier can be used for a class so that its members can be accessed by a different class in a different package. Public access allows unrestricted access to the class and its members from any other class or package. This means that the class and its members can be accessed and used by any other class, regardless of the package they belong to.

    Rate this question:

  • 40. 

    Which of these class is superclass of String and StringBuffer class?

    • A.

      Java.util

    • B.

      Java.lang

    • C.

      ArrayList

    • D.

      None of the mentioned

    Correct Answer
    B. Java.lang
    Explanation
    The correct answer is java.lang. The java.lang package is a default package in Java that contains classes that are fundamental to the language. Both the String and StringBuffer classes are part of this package. Therefore, java.lang is the superclass of both String and StringBuffer classes.

    Rate this question:

  • 41. 

    Which of these operators can be used to concatenate two or more String objects?

    • A.

      +

    • B.

      +=

    • C.

      &

    • D.

      ||

    Correct Answer
    A. +
    Explanation
    The + operator can be used to concatenate two or more String objects. This operator is used to combine the contents of two strings into a single string. For example, if we have two strings "Hello" and "World", using the + operator we can concatenate them as "HelloWorld".

    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
  • Mar 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 09, 2017
    Quiz Created by
    Catherine Halcomb
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.