Mld1 Mid-term Exam Part1

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 Teacherv
T
Teacherv
Community Contributor
Quizzes Created: 5 | Total Attempts: 509
Questions: 10 | Attempts: 93

SettingsSettingsSettings
Mld1 Mid-term Exam Part1 - Quiz


MLD1 Mid-Term Exam Part1


Questions and Answers
  • 1. 

    To make variable "dat" equal to 5 which of the following lines of Java code should be used:

    • A.

      Int dat = 5;

    • B.

      String dat = 5;

    • C.

      System.print.out(dat);

    • D.

      Dat = dat + 5;

    Correct Answer
    A. Int dat = 5;
    Explanation
    The correct answer is "int dat = 5;". This line of code declares a variable named "dat" of type integer and assigns it the value of 5. This will make the variable "dat" equal to 5. The other options are incorrect because they either assign a string value to the variable or attempt to print the value without declaring the variable first.

    Rate this question:

  • 2. 

    To make a Java program print "Java", which of the following lines of Java code should be used:

    • A.

      Print(Java);

    • B.

      Print"Java";

    • C.

      System.out.print "Java";

    • D.

      System.out.print("Java");

    Correct Answer
    D. System.out.print("Java");
    Explanation
    The correct answer is System.out.print("Java"). This is because System.out.print is a method in Java that is used to print the specified text to the console. In this case, "Java" is the text that we want to print. The correct syntax for calling this method is to use parentheses () to enclose the text that we want to print. Therefore, the correct line of code to make a Java program print "Java" is System.out.print("Java").

    Rate this question:

  • 3. 

    A program "class SavProg2" should be saved as:

    • A.

      SavProg2

    • B.

      SavProg2.txt

    • C.

      SavProg2.java

    • D.

      Class SavProg2.java

    Correct Answer
    C. SavProg2.java
    Explanation
    The correct answer is "SavProg2.java" because in Java, the convention is to save a program file with the same name as the main class in the program. In this case, the main class is "SavProg2", so the file should be saved as "SavProg2.java".

    Rate this question:

  • 4. 

    Which character usually ends up a Java program code?

    • A.

      @

    • B.

      }

    • C.

      &

    • D.

      #

    Correct Answer
    B. }
    Explanation
    The character "}" usually ends up a Java program code. This character is used to close a block of code, such as a class, method, or loop. It is important to have matching opening and closing braces to ensure the code is properly structured and executed. The other characters mentioned (@, &, #) do not typically signify the end of a Java program code.

    Rate this question:

  • 5. 

    You cannot compile your Java program until you

    • A.

      Erase it

    • B.

      Run it

    • C.

      Save it

    • D.

      Memorize it

    Correct Answer
    C. Save it
    Explanation
    To compile a Java program, it needs to be saved first. Saving the program ensures that the changes made to the code are stored in a file on the computer's storage. Once the program is saved, it can be compiled using a Java compiler, which will translate the code into a format that can be executed by the computer. Therefore, saving the Java program is a necessary step before compiling it.

    Rate this question:

  • 6. 

    A Java class code contains the following line:public class Diamondwhat is the actual name of the program (class)?

    • A.

      Public static void class Diamond

    • B.

      Class Diamond

    • C.

      Diamond

    • D.

      Diamond

    Correct Answer
    C. Diamond
    Explanation
    The actual name of the program (class) is "Diamond". This is because in Java, the name of the class should match the name given after the "public class" statement. So, in this case, the name of the class is "Diamond".

    Rate this question:

  • 7. 

    A computer keyboard is a:

    • A.

      The main part of a computer

    • B.

      Output device

    • C.

      Input device

    • D.

      Storage device

    Correct Answer
    C. Input device
    Explanation
    A computer keyboard is classified as an input device because it allows users to input data and commands into a computer system. It consists of various keys that can be pressed to type letters, numbers, and special characters. The input from the keyboard is then processed by the computer's operating system or software applications. Keyboards are essential for tasks such as typing documents, sending emails, playing games, and navigating through computer interfaces.

    Rate this question:

  • 8. 

    The line of Java code below has the last character missed.answer = number1 + 3The missed character is:

    • A.

      @

    • B.

      /

    • C.

      &

    • D.

      ;

    Correct Answer
    D. ;
    Explanation
    The missing character in the given line of Java code is a semicolon (;). A semicolon is used to indicate the end of a statement in Java. In this code, the semicolon is missing after the expression "number1 + 3", which is a syntax error. Adding the semicolon at the end will correct the code.

    Rate this question:

  • 9. 

    The text below is a fragment of a Java code. public class CalcNum {public static void main(String[] args) {double circ = 0This code should be saved as:

    • A.

      Public class CalcNum

    • B.

      CalcNum.java

    • C.

      Class CalcNum

    • D.

      Class CalcNum.java

    Correct Answer
    B. CalcNum.java
    Explanation
    The correct answer is "CalcNum.java" because the code is defining a public class called "CalcNum" and the convention in Java is to save a public class in a file with the same name as the class, followed by the ".java" extension.

    Rate this question:

  • 10. 

    An integer is:

    • A.

      Any whole number (includes positive, negative, and zero)

    • B.

      A whole number or a decimal

    • C.

      A negative whole number

    • D.

      A fraction

    Correct Answer
    A. Any whole number (includes positive, negative, and zero)
    Explanation
    The correct answer is any whole number (includes positive, negative, and zero). This is because an integer is defined as a number that does not have a fractional or decimal part. It can be positive, negative, or zero, but it must be a whole number.

    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
  • Jan 17, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 05, 2009
    Quiz Created by
    Teacherv
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.