Mld1 Class Final Review Part1

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Teacherv
T
Teacherv
Community Contributor
Quizzes Created: 5 | Total Attempts: 514
| Attempts: 102
SettingsSettings
Please wait...
  • 1/10 Questions

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

    • #
    • {
    • "
    • ;
Please wait...
About This Quiz

This 'MLD1 Class Final Review Part1' quiz assesses key Java programming skills. It covers syntax, code saving conventions, variable operations, and output methods. Ideal for learners aiming to solidify their Java knowledge before exams.

Mld1 Class Final Review Part1 - Quiz

Quiz Preview

  • 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:

    • Public class.java

    • Class Random.java

    • Random.java

    • Random.java

    Correct Answer
    A. 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:

    • RMath is a name of an undefined variable

    • RMath is a variable and its value is an integer

    • RMath is the name of the program

    • Int rMath is a typo and should be fixed

    Correct Answer
    A. 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:

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

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

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

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

    Correct Answer
    A. 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:

    • They do exactly the same thing.

    • They print out different numbers.

    • 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.

    • None of the above is true for these two lines.

    Correct Answer
    A. 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:

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

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

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

    • 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

    • Variable "sum" will be multiplied by 2.

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

    • There are actually 2 variables called "sum".

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

    Correct Answer
    A. 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:

    • The next string has its own name "Student"

    • Student's name must be typed in.

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

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

    Correct Answer
    A. "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:

    • }

    • )

    • ]

    • ()

    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 positive whole number

    • A decimal

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

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

    Rate this question:

Quiz Review Timeline (Updated): Feb 19, 2024 +

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.