Quiz No. 2 In Java Programming

  • 8th Grade,
  • 9th Grade,
  • 10th Grade
  • IEEE
  • ACM
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 Ricador
R
Ricador
Community Contributor
Quizzes Created: 14 | Total Attempts: 57,217
| Attempts: 2,306 | Questions: 30 | Updated: Mar 21, 2025
Please wait...
Question 1 / 31
🏆 Rank #--
Score 0/100

1. Select C if the given statement is CORRECT, otherwise select I.      System.in.print('number');

Explanation

The given statement is incorrect because the correct syntax to print something to the console in Java is System.out.print(), not System.in.print(). System.in is used for input from the user, while System.out is used for output to the console.

Submit
Please wait...
About This Quiz
Quiz No. 2 In Java Programming - Quiz

The quiz is about identification of the correct or incorrect declaration of identifiers and Java statements. (Valid or Invalid / Correct or Incorrect)

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Select C if the given statement is CORRECT, otherwise select I.      int number1=23.45;

Explanation

The given statement is incorrect because the variable "number1" is declared as an integer, but it is assigned a decimal value (23.45). In Java, integers can only hold whole numbers, so the correct data type for the given value would be double or float.

Submit

3. Select C if the given statement is CORRECT, otherwise select I.      double 56;

Explanation

The given statement "double 56" is incorrect. In programming, "double" is a data type used to store decimal numbers with double precision. However, in this statement, "double" is being used as a variable name, which is not allowed. Variable names cannot start with a number, and "56" is not a valid variable name. Therefore, the statement is incorrect.

Submit

4. Select V if the identifier below is VALID, otherwise select I.      ==counter

Explanation

The identifier "==counter" is not valid because it starts with a double equals sign, which is not allowed in most programming languages. Identifiers should typically start with a letter or an underscore, followed by letters, numbers, or underscores.

Submit

5. Select C if the given statement is CORRECT, otherwise select I.      char next_line="\n");

Explanation

The given statement is incorrect because it contains syntax errors. The variable "next_line" is assigned with a value that is not a valid character. The correct way to assign a new line character to a char variable is by using '\n' instead of "".

Submit

6. Select C if the given statement is CORRECT, otherwise select I.      /* This is a single line comment

Explanation

The given statement is incorrect. The correct syntax for a single line comment in most programming languages is "//" or "#" depending on the language. The statement provided, "/* This is a single line comment", is actually a multi-line comment syntax in some programming languages like C or C++.

Submit

7. Select V if the identifier below is VALID, otherwise select I.      2nd_num

Explanation

The identifier "2nd_num" is not valid because it starts with a number, which is not allowed in most programming languages. Identifiers typically need to start with a letter or an underscore.

Submit

8. Select V if the identifier below is VALID, otherwise select I.      *pointer

Explanation

The identifier "*pointer" is not valid because it starts with an asterisk symbol (*), which is not allowed in variable names. Variable names in most programming languages can only contain letters, numbers, and underscores, and must start with a letter or an underscore.

Submit

9. Select C if the given statement is CORRECT, otherwise select I.      System.out.pritnln("Java Programming is COOL!");

Explanation

The given statement is correct because it is using the correct syntax to print the string "Java Programming is COOL!" using the System.out.println() method in Java.

Submit

10. Select V if the identifier below is VALID, otherwise select I.      Strong

Explanation

The identifier "Strong" is valid because it follows the rules for naming identifiers. In most programming languages, identifiers can consist of letters, numbers, and underscores, and can start with a letter or an underscore. Since "Strong" consists only of letters and starts with a capital letter, it is considered a valid identifier.

Submit

11. Select V if the identifier below is VALID, otherwise select I.      initial

Explanation

The identifier "initial" is valid because it follows the rules for naming identifiers in most programming languages. It starts with a letter and can be followed by letters, numbers, or underscores.

Submit

12. Select V if the identifier below is VALID, otherwise select I.      large

Explanation

The identifier "large" is a valid identifier because it starts with a letter and does not contain any special characters or spaces. It follows the rules for naming identifiers in programming languages.

Submit

13. Select V if the identifier below is VALID, otherwise select I.      cake

Explanation

The identifier "cake" is valid because it follows the rules for naming identifiers. It starts with a letter, does not contain any special characters or spaces, and is not a reserved keyword. Therefore, it can be used as a valid identifier in a programming language.

Submit

14. Select V if the identifier below is VALID, otherwise select I.      Default

Explanation

The identifier "Default" is valid because it follows the rules for naming identifiers. In most programming languages, identifiers can consist of letters, numbers, and underscores, and can start with a letter or an underscore. Since "Default" only contains letters and starts with a capital letter, it is a valid identifier.

Submit

15. Select C if the given statement is CORRECT, otherwise select I.      System.out.println('Welcome to Java');

Explanation

The given statement is incorrect because the println() method in Java requires a string argument to be passed inside the parentheses. In this case, 'Welcome to Java' is not enclosed in double quotes, which makes it a character literal instead of a string literal. To make the statement correct, it should be written as System.out.println("Welcome to Java");

Submit

16. Select C if the given statement is CORRECT, otherwise select I.      Public class SECOND {

Explanation

The given statement is incorrect because the correct way to declare a public class in Java is by using the keyword "public" followed by the class name. In this case, the class name is "SECOND". Therefore, the correct statement should be "public class SECOND".

Submit

17. Select V if the identifier below is VALID, otherwise select I.      Main

Explanation

The identifier "Main" is valid because it starts with a capital letter and does not contain any special characters or spaces. In programming, identifiers are used to name variables, functions, or other entities, and they must follow certain rules and conventions. In this case, "Main" follows the convention of using a capital letter for the start of the identifier, making it a valid choice.

Submit

18. Select V if the identifier below is VALID, otherwise select I.      b

Explanation

The identifier "b" is a valid identifier because it consists of a single letter. In programming, identifiers are used to name variables, functions, or other entities, and they must follow certain rules. In this case, the identifier "b" meets the requirement of being a valid identifier as it is a single letter.

Submit

19. Select C if the given statement is CORRECT, otherwise select I.      public static main void (String args[]){

Explanation

The given statement is incorrect because the "main" method in Java should have a return type of "void" and the correct syntax for the main method is "public static void main(String[] args)".

Submit

20. Select C if the given statement is CORRECT, otherwise select I.      char gender="m";

Explanation

The given statement is incorrect because the variable "gender" is assigned the value "m" without being declared as a char data type.

Submit

21. Select C if the given statement is CORRECT, otherwise select I.      int

Explanation

The given statement "int" is not a complete statement and does not provide any information or context. Therefore, it is incorrect to say that the statement is correct.

Submit

22. Select V if the identifier below is VALID, otherwise select I.      int

Explanation

The given identifier "int" is not valid because it is a reserved keyword in many programming languages, including C++, Java, and C#. Reserved keywords cannot be used as identifiers in the code.

Submit

23. Select C if the given statement is CORRECT, otherwise select I.      float a, int b;

Explanation

The given statement is incorrect because it is not possible to declare a float variable and an int variable in the same line without specifying the variable names.

Submit

24. Select V if the identifier below is VALID, otherwise select I.      _Public

Explanation

The identifier "_Public" is valid because it starts with an underscore, which is a valid character for identifiers in many programming languages.

Submit

25. Select V if the identifier below is VALID, otherwise select I.      Byte

Explanation

The identifier "Byte" is valid because it starts with a capital letter, which is allowed in most programming languages. It also consists of only letters, which is another valid character for an identifier. Therefore, "Byte" meets the criteria for a valid identifier.

Submit

26. Select C if the given statement is CORRECT, otherwise select I.      Boolean a;

Explanation

The given statement "Boolean a;" is incorrect because it is missing the variable declaration and initialization. In Java, when declaring a variable, we need to specify its type and give it a name. Additionally, we should also assign a value to the variable. Therefore, the correct statement should be something like "boolean a = false;" where "boolean" is the type, "a" is the variable name, and "false" is the initial value.

Submit

27. Select C if the given statement is CORRECT, otherwise select I.      public static void main (string [] args) {

Explanation

The given statement is incorrect because the "string" keyword should be capitalized as "String" in Java.

Submit

28. Select V if the identifier below is VALID, otherwise select I.      char

Explanation

The identifier "char" is not a valid identifier because it is a reserved keyword in many programming languages, including C, C++, and Java. Reserved keywords have a predefined meaning in the language and cannot be used as identifiers for variables, functions, or other entities in the code. Therefore, "char" cannot be used as a valid identifier.

Submit

29. Select V if the identifier below is VALID, otherwise select I.      short

Explanation

The identifier "short" is not valid because it is a reserved keyword in many programming languages, including C and C++. Reserved keywords cannot be used as identifiers because they have special meanings in the language.

Submit

30. Select C if the given statement is CORRECT, otherwise select I.      Short classes=19;

Explanation

The given statement is incorrect because in most programming languages, the syntax for declaring a variable and assigning a value to it is "data type variableName = value;" rather than "variableName = value;". Therefore, the correct answer is I.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
Select C if the given statement is CORRECT,...
Select V if the identifier below is VALID, otherwise select...
Select V if the identifier below is VALID, otherwise select...
Select C if the given statement is CORRECT,...
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!