Java Programming MCQ Exam: Quiz

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 Myhemant72
M
Myhemant72
Community Contributor
Quizzes Created: 4 | Total Attempts: 8,586
Questions: 10 | Attempts: 475

SettingsSettingsSettings
Java Programming MCQ Exam: Quiz - Quiz

.


Questions and Answers
  • 1. 

    Int i; int sum=0; for(i=2;i<=10;i+=2)    sum+=i; System.out.println(""+sum); what is the output of the above program?

    • A.

      28

    • B.

      30

    • C.

      32

    • D.

      34

    Correct Answer
    B. 30
    Explanation
    The given program initializes a variable 'sum' to 0. Then, it enters a for loop with the variable 'i' starting from 2 and incrementing by 2 until it reaches 10. Inside the loop, it adds the value of 'i' to 'sum'. After the loop, it prints the value of 'sum'. Since the loop adds all even numbers from 2 to 10, the final value of 'sum' is 30. Therefore, the output of the program is 30.

    Rate this question:

  • 2. 

    String str1="Raj",str2="Kumar"; String str3=str1+ " " + str2; System.out.println(""+str3); what  is the output of the above program?

    • A.

      RajKumar

    • B.

      Raj Kumar

    • C.

      Rajeev Kumar

    • D.

      Null

    Correct Answer
    B. Raj Kumar
    Explanation
    The given code concatenates the strings "Raj" and "Kumar" with a space in between using the + operator. The result is stored in the variable str3. Finally, the code prints the value of str3, which is "Raj Kumar". Therefore, the output of the program is "Raj Kumar".

    Rate this question:

  • 3. 

    Int X=10; int a=12,b=5; int c=(int)a/b; switch(c) {    case 1:              X=X+2;    case 2:             X=X + 2;     default :            X=X+1; } System.out.println(""+X);

    • A.

      15

    • B.

      13

    • C.

      10

    • D.

      12

    Correct Answer
    B. 13
    Explanation
    In this code, the value of 'c' is calculated by dividing 'a' by 'b'. Since 'a' and 'b' are both integers, the result will be an integer. In this case, 'a' divided by 'b' is 2. The switch statement then checks the value of 'c'. Since 'c' is 2, it matches the case 2 and the code inside that case is executed. This code adds 2 to the value of 'X', making it 12. However, there is no break statement after this case, so the code continues to execute the default case. The code inside the default case adds 1 to the value of 'X', making it 13. Therefore, the final value of 'X' is 13, which is the correct answer.

    Rate this question:

  • 4. 

    Int day=5; switch(day) {   case 10:                System.out.println("India");   default :              System.out.println("Invalid"); } What will be the output of the above program?

    • A.

      India

    • B.

      Invalid

    • C.

      Error

    • D.

      No output

    Correct Answer
    B. Invalid
    Explanation
    The output of the above program will be "Invalid". This is because the value of the variable "day" is 5, which does not match any of the cases in the switch statement. Therefore, the default case will be executed, and "Invalid" will be printed.

    Rate this question:

  • 5. 

    In which phase you will check if the software is according to user specifications?

    • A.

      Maintenance

    • B.

      Deployment

    • C.

      Testing

    • D.

      Coding

    Correct Answer
    C. Testing
    Explanation
    In the testing phase, the software is checked to ensure that it meets the user specifications. This phase involves running various tests to identify any errors, bugs, or discrepancies in the software's functionality. By conducting thorough testing, developers can verify that the software performs as intended and meets the requirements set by the users. This phase is crucial in ensuring the quality and reliability of the software before it is deployed or released to the users.

    Rate this question:

  • 6. 

    What will happen if you do not specify a condition in delete statement?

    • A.

      No records will be deleted

    • B.

      All records will be deleted

    • C.

      Some records are deleted

    • D.

      Some records are not deleted

    Correct Answer
    B. All records will be deleted
    Explanation
    If you do not specify a condition in a delete statement, it means that the delete statement will not have any criteria to determine which records should be deleted. As a result, all records in the table will be considered for deletion and ultimately, all records will be deleted from the table.

    Rate this question:

  • 7. 

    Which of the following are open source? 

    • A.

      Microsoft Office

    • B.

      Netbeans

    • C.

      MYSQL

    • D.

      Outlook Express

    Correct Answer(s)
    B. Netbeans
    C. MYSQL
    Explanation
    Netbeans and MYSQL are open source. Netbeans is an open-source integrated development environment (IDE) used for Java, while MYSQL is an open-source relational database management system. Open source means that the source code of the software is freely available for anyone to view, modify, and distribute. Microsoft Office and Outlook Express are not open source as they are proprietary software developed by Microsoft.

    Rate this question:

  • 8. 

    Select length('Raj Kumar');

    • A.

      8

    • B.

      9

    • C.

      10

    • D.

      11

    Correct Answer
    B. 9
    Explanation
    The given SQL query is selecting the length of the string 'Raj Kumar'. The length function in SQL returns the number of characters in a string. In this case, the string 'Raj Kumar' has a length of 9 characters, so the correct answer is 9.

    Rate this question:

  • 9. 

    Net beans is an IDE?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    NetBeans is an integrated development environment (IDE) used primarily for Java programming. It provides tools and features to support the development of Java applications, including a code editor, debugger, and graphical user interface builder. Therefore, the statement "NetBeans is an IDE" is true.

    Rate this question:

  • 10. 

    Which of the following are DML statements?

    • A.

      Insert

    • B.

      Update

    • C.

      Delete

    • D.

      Create

    • E.

      Drop

    Correct Answer(s)
    A. Insert
    B. Update
    C. Delete
    Explanation
    The correct answer is Insert, Update, and Delete. These three statements are known as Data Manipulation Language (DML) statements in SQL. They are used to manipulate data in a database. The Insert statement is used to insert new rows of data into a table, the Update statement is used to modify existing data in a table, and the Delete statement is used to remove rows of data from a table. Create and Drop are not DML statements, they are Data Definition Language (DDL) statements used to create and drop tables.

    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
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 24, 2013
    Quiz Created by
    Myhemant72
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.