Quiz No. 1 In Java Programming

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 Ricador
R
Ricador
Community Contributor
Quizzes Created: 14 | Total Attempts: 54,656
Questions: 20 | Attempts: 8,197

SettingsSettingsSettings
Quiz No. 1 In Java Programming - Quiz

The quiz is about the basic terminologies in Java programming. It also includes array declaration and the application of operators.


Questions and Answers
  • 1. 

    Using the declaration below, what will be the final element of the array? int [ ] grades = new int[35];

    • A.

      Grades[0]

    • B.

      Grades[34]

    • C.

      Grades[35]

    • D.

      Impossible to tell

    Correct Answer
    B. Grades[34]
    Explanation
    The final element of the array will be grades[34] because arrays in Java are zero-indexed, meaning the first element is at index 0 and the last element is at index (length - 1). Since the array has a length of 35, the indexes will range from 0 to 34. Therefore, grades[34] will refer to the final element of the array.

    Rate this question:

  • 2. 

    It is the Java keyword that creates inheritance.

    • A.

      Enlarge

    • B.

      Extends

    • C.

      Inherits

    • D.

      Inheritance

    Correct Answer
    B. Extends
    Explanation
    The correct answer is "extends". In Java, the "extends" keyword is used to create inheritance. It allows a subclass to inherit the properties and methods of a superclass. By using "extends", the subclass can access and use the variables and methods defined in the superclass, promoting code reuse and creating a hierarchical relationship between classes.

    Rate this question:

  • 3. 

    It is the rules of a programming language.

    • A.

      Format

    • B.

      Logic

    • C.

      Object

    • D.

      Syntax

    Correct Answer
    D. Syntax
    Explanation
    The correct answer is "syntax" because it refers to the set of rules that determine the structure and format of a programming language. Syntax is important in programming as it dictates how code should be written in order for it to be understood and executed correctly by the computer. It specifies the correct order and arrangement of keywords, symbols, and punctuation marks, ensuring that the code is valid and can be interpreted by the compiler or interpreter.

    Rate this question:

  • 4. 

    It is the code/s inside a pair of curly braces.

    • A.

      Block

    • B.

      Brick

    • C.

      Function

    • D.

      Method

    Correct Answer
    A. Block
    Explanation
    A block refers to a section of code enclosed within a pair of curly braces. It is used to group statements together and define a scope. Blocks are commonly used in programming languages to create loops, conditional statements, and define functions or methods. The code inside a block is executed sequentially and can have its own local variables and logic. Therefore, the correct answer is "block".

    Rate this question:

  • 5. 

    If A=10, then after B=++A, the value of B is _______.

    • A.

      10

    • B.

      11

    • C.

      12

    • D.

      13

    Correct Answer
    B. 11
    Explanation
    When B=++A, the value of A is first incremented by 1, making it 11. Then, the value of B is assigned the value of A, which is 11. Therefore, the value of B is 11.

    Rate this question:

  • 6. 

    It is the characteristics of Java which ensures that a program can go only where it is designed to go and eliminates the possibility of altering system data unintentionally.

    • A.

      Java is simple.

    • B.

      Java is secure.

    • C.

      Java is free.

    • D.

      Java is portable.

    Correct Answer
    B. Java is secure.
    Explanation
    Java's security features, such as its bytecode verification and sandboxing, ensure that a program cannot access or modify system data without explicit permission. This prevents unintentional alteration of system data and protects against malicious attacks. Java's security measures also include a robust permission system, cryptography support, and a strong emphasis on secure coding practices. Overall, Java's focus on security makes it a reliable and trustworthy programming language for developing secure applications.

    Rate this question:

  • 7. 

    It is a form of Java program that runs locally on the command line.

    • A.

      Applets

    • B.

      Application

    • C.

      Midlets

    • D.

      Servlets

    Correct Answer
    B. Application
    Explanation
    An application is a type of Java program that is designed to run locally on the command line. Unlike applets, which are typically embedded within web pages, and midlets, which are designed for mobile devices, applications are standalone programs that can be executed directly on a computer. Servlets, on the other hand, are Java programs that are designed to run on a web server and generate dynamic web content. Therefore, the correct answer is application.

    Rate this question:

  • 8. 

    It defines the common variables and methods of a set of objects.

    • A.

      Objects

    • B.

      Class

    • C.

      Function

    • D.

      Method

    Correct Answer
    B. Class
    Explanation
    This statement explains that a class defines the common variables and methods of a set of objects. In object-oriented programming, a class serves as a blueprint or template for creating objects. It encapsulates data (variables) and behavior (methods) that are shared by multiple objects of the same type. By defining a class, we can create multiple instances (objects) that inherit the properties and behaviors defined within the class.

    Rate this question:

  • 9. 

    It is the process of removing errors found in the program.

    • A.

      Editing

    • B.

      Debugging

    • C.

      Compiling

    • D.

      Running

    Correct Answer
    B. Debugging
    Explanation
    Debugging is the process of identifying and removing errors or bugs found in a program. It involves analyzing the code, identifying the cause of the error, and making the necessary corrections to fix it. Debugging is an essential step in the software development process as it ensures that the program functions correctly and produces the expected results. It helps improve the overall quality and reliability of the program by eliminating any issues or inconsistencies.

    Rate this question:

  • 10. 

    Which of the following is the data type used for a single character?

    • A.

      Byte

    • B.

      Short

    • C.

      Long

    • D.

      Char

    Correct Answer
    D. Char
    Explanation
    The data type used for a single character is char.

    Rate this question:

  • 11. 

    Which symbol is used to denote a multi-line comment?

    • A.

      / /

    • B.

      /* */

    • C.

      { }

    • D.

      < >

    Correct Answer
    B. /* */
    Explanation
    The symbol /* */ is used to denote a multi-line comment in many programming languages, including C, C++, Java, and JavaScript. This allows developers to add explanatory or descriptive text within their code without affecting the program's functionality. Anything between /* and */ is ignored by the compiler or interpreter, making it useful for adding notes, documentation, or temporarily disabling code.

    Rate this question:

  • 12. 

    Which of the following is not a unary operator?

    • A.

      Negation

    • B.

      Decrement

    • C.

      Bitwise complement

    • D.

      Assignment

    Correct Answer
    D. Assignment
    Explanation
    The given question asks for a unary operator, which means an operator that operates on a single operand. The options "negation," "decrement," and "bitwise complement" are all unary operators as they each operate on a single operand. However, "assignment" is not a unary operator as it is used to assign a value to a variable, rather than operating on a single operand.

    Rate this question:

  • 13. 

    Which of the following is not a Java keyword?

    • A.

      Default

    • B.

      For

    • C.

      Volatile

    • D.

      Of

    Correct Answer
    D. Of
    Explanation
    The keyword "of" is not a valid Java keyword. Java keywords are reserved words that have a specific meaning and cannot be used as identifiers. "Default", "for", and "volatile" are all valid Java keywords. However, "of" is not a keyword in Java and cannot be used as a keyword in Java programs.

    Rate this question:

  • 14. 

    Which of the following is not a primitive data type?

    • A.

      Byte

    • B.

      String

    • C.

      Char

    • D.

      Long

    Correct Answer
    B. String
    Explanation
    The String data type is not a primitive data type because it is a class in Java. Primitive data types are the basic building blocks of data in a programming language, while String is an object that represents a sequence of characters.

    Rate this question:

  • 15. 

    Which of the following is an invalid first character of an identifier?

    • A.

      __

    • B.

      $

    • C.

      A

    • D.

      8

    Correct Answer
    D. 8
    Explanation
    The first character of an identifier cannot be a number. In programming languages, identifiers are used to name variables, functions, and other entities. They must follow certain rules, and one of them is that they cannot start with a number. Therefore, option 8 is an invalid first character for an identifier.

    Rate this question:

  • 16. 

    It is the length of the data type float.

    • A.

      8 bits

    • B.

      12 bits

    • C.

      16 bits

    • D.

      32 bits

    Correct Answer
    D. 32 bits
    Explanation
    The correct answer is 32 bits because the data type float in most programming languages typically occupies 32 bits of memory. This allows it to store a wide range of decimal values with a reasonable level of precision.

    Rate this question:

  • 17. 

    It is the length of the data type short.

    • A.

      8 bits

    • B.

      16 bits

    • C.

      32 bits

    • D.

      64 bits

    Correct Answer
    B. 16 bits
    Explanation
    The correct answer is 16 bits because the question states that it is the length of the data type short. In most programming languages, a short data type is typically represented by 16 bits, allowing it to store integer values ranging from -32,768 to 32,767.

    Rate this question:

  • 18. 

    Which of the following is an invalid variable declaration in Java?

    • A.

      Int NumberOfStudents = 250;

    • B.

      Double Salary =0.0;

    • C.

      String NAME =

    • D.

      Char CivilStatus =

    Correct Answer
    D. Char CivilStatus =
    Explanation
    The variable declaration "char CivilStatus =" is invalid in Java because it is missing a value assignment. In Java, when declaring a variable, it is necessary to assign a value to it. In this case, the value for the variable "CivilStatus" is missing, making the declaration incomplete and invalid.

    Rate this question:

  • 19. 

    It terminates every line of code in Java.

    • A.

      }

    • B.

      )

    • C.

      ;

    • D.

      .

    Correct Answer
    C. ;
    Explanation
    The semicolon (;) is used to terminate every line of code in Java. It indicates the end of a statement or expression. Without a semicolon, the code will result in a compilation error. Therefore, it is necessary to include a semicolon at the end of each line in Java to ensure proper syntax and execution of the program.

    Rate this question:

  • 20. 

    It is the command used to compile Java program in the command prompt.

    • A.

      Ja

    • B.

      Jav

    • C.

      Java

    • D.

      Javac

    Correct Answer
    D. Javac
    Explanation
    The command "javac" is used to compile Java programs in the command prompt. It is used to convert the human-readable Java source code into machine-readable bytecode that can be executed by the Java Virtual Machine (JVM). This command is an essential part of the Java development process as it ensures that the code is error-free and ready for execution.

    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.