Mld1 Class Final Review 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: 512
Questions: 10 | Attempts: 102

SettingsSettingsSettings
Mld1 Class Final Review Part1 - Quiz


MLD1 Class Mid-Term Review Part1


Questions and Answers
  • 1. 

    The line of Java code below has the last character missed.int lastOne = 3The missed character is:

    • A.

      #

    • B.

      {

    • C.

      "

    • D.

      ;

    Correct Answer
    D. ;
    Explanation
    The missed character in the line of Java code is ";". This is because the line of code is declaring a variable named "lastOne" and assigning it a value of 3. In Java, it is necessary to end statements with a semicolon (;) to indicate the end of the line of code.

    Rate this question:

  • 2. 

    The text below is a fragment of a Java code. public class Random {public static void main(String[] args) {int rMath = Math.random()*100 == This code should be saved as:

    • A.

      Public class.java

    • B.

      Class Random.java

    • C.

      Random.java

    • D.

      Random.java

    Correct Answer
    C. Random.java
    Explanation
    The code is defining a class named "Random" and declaring a main method within it. The main method initializes an integer variable called "rMath" and assigns the result of the expression "Math.random()*100" to it. The double value returned by Math.random() is multiplied by 100 and then compared to 0. Since the result of this comparison is a boolean value, it cannot be assigned to the integer variable "rMath" as it expects an integer value. Therefore, the code has an error and should be saved as "Random.java".

    Rate this question:

  • 3. 

    According to the Java program code fragment below,public class Random { public static void main(String[] args) { int rMath = Math.random()*100 == int rMath means:

    • A.

      RMath is a name of an undefined variable

    • B.

      RMath is a variable and its value is an integer

    • C.

      RMath is the name of the program

    • D.

      Int rMath is a typo and should be fixed

    Correct Answer
    B. RMath is a variable and its value is an integer
    Explanation
    The code fragment declares a variable named rMath, indicating that rMath is a variable. Additionally, the code assigns the result of the expression Math.random()*100 to rMath, which implies that its value is an integer.

    Rate this question:

  • 4. 

    The following line of a Java code:System.out.println("The number = " + num);makes the computer to:

    • A.

      Print a new line "The number = + num".

    • B.

      Print a new line "The number = " and then the value of the variable "num".

    • C.

      Prints a line "The number = + num" on a paper using a printer.

    • D.

      Prints a new line showing only the value of the variable "num".

    Correct Answer
    B. Print a new line "The number = " and then the value of the variable "num".
    Explanation
    The given line of code, System.out.println("The number = " + num), will print a new line "The number = " followed by the value of the variable "num". The "+" operator is used to concatenate the string "The number = " with the value of the variable "num", resulting in the desired output.

    Rate this question:

  • 5. 

    For the code line: System.out.println("The number = " + num); and the code line:System.out.print("The number = " + num);,the following is true:

    • A.

      They do exactly the same thing.

    • B.

      They print out different numbers.

    • C.

      The first one makes the continuation of the text/information to be printed on the next line. The second does not, so that the new information would be printed on the same line.

    • D.

      None of the above is true for these two lines.

    Correct Answer
    C. The first one makes the continuation of the text/information to be printed on the next line. The second does not, so that the new information would be printed on the same line.
    Explanation
    The first code line, System.out.println("The number = " + num);, prints the text "The number =" followed by the value of the variable "num" on the next line. The second code line, System.out.print("The number = " + num);, prints the same text and value, but without moving to the next line. Therefore, the first code line makes the continuation of the text/information to be printed on the next line, while the second code line does not.

    Rate this question:

  • 6. 

    The line: tenPercentTax = 0.10*(netIncome - 30000);means:

    • A.

      The value of the variable "tenPercentTax" equals to the result of (netIncome - 30000) times 0.10

    • B.

      The value of the variable "tenPercentTax" equals to the result of 0.10 times the variable "netIncome" and then minus 30000.

    • C.

      The value of the variable "tenPercentTax" equals to the result of 0.10 times 30000 and then minus the variable "netIncome".

    • D.

      The value of the variable "tenPercentTax" equals to the result of 0.10 times negative 30000.

    Correct Answer
    A. The value of the variable "tenPercentTax" equals to the result of (netIncome - 30000) times 0.10
    Explanation
    The correct answer is the value of the variable "tenPercentTax" equals to the result of (netIncome - 30000) times 0.10. This means that the variable "tenPercentTax" is calculated by subtracting 30000 from the net income and then multiplying that result by 0.10, which represents 10% in decimal form. This calculation allows for the determination of the ten percent tax based on the net income.

    Rate this question:

  • 7. 

    The word "double" in the following Java code line:double sum =means that

    • A.

      Variable "sum" will be multiplied by 2.

    • B.

      The memory space for the variable "sum" will be twice more than a regular one.

    • C.

      There are actually 2 variables called "sum".

    • D.

      Variable "sum" may not have more than 2 digits.

    Correct Answer
    B. The memory space for the variable "sum" will be twice more than a regular one.
    Explanation
    The word "double" in the given Java code line indicates that the memory space for the variable "sum" will be twice as large as a regular variable. In Java, the "double" data type is used to represent decimal numbers with double precision, which requires more memory compared to regular data types like "int" or "float". Therefore, using "double" for the variable "sum" implies that it can store larger decimal values with higher precision.

    Rate this question:

  • 8. 

    In Java code, The following line:String name = "Student";actually means:

    • A.

      The next string has its own name "Student"

    • B.

      Student's name must be typed in.

    • C.

      "name" is a text variable and its value is the word "String"

    • D.

      "name" is a text variable and its value is the word "Student"

    Correct Answer
    D. "name" is a text variable and its value is the word "Student"
    Explanation
    The given correct answer for this question is "name" is a text variable and its value is the word "Student". This is because the line of code "String name = "Student";" declares a variable named "name" of type String and assigns it the value "Student".

    Rate this question:

  • 9. 

    A Java class code ends with:

    • A.

      }

    • B.

      )

    • C.

      ]

    • D.

      ()

    Correct Answer
    A. }
    Explanation
    In Java, a class code ends with a closing curly brace (}). This is because the opening curly brace ({) denotes the start of the class code block, and the closing curly brace marks the end of the code block. It is important to have a balanced number of opening and closing curly braces to ensure that the code is syntactically correct. The other options, such as ), ] and (), are not used to end a class code in Java.

    Rate this question:

  • 10. 

    An integer is:

    • A.

      A positive whole number

    • B.

      A decimal

    • C.

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

    • D.

      A fraction

    Correct Answer
    C. 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, and it includes all whole numbers.

    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
  • Feb 19, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 30, 2009
    Quiz Created by
    Teacherv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.