Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 2 subjective questions Loops, Arrays, and OOP Concepts

CSE310 — Programming In Java 20 questions with model answers. Write yours first, then compare.

Read the notes Practice MCQs
  1. Question 1 of 20

    Differentiate between the while loop and the do-while loop in Java with syntax and examples.

  2. Question 2 of 20

    Explain the concept of the Enhanced for-loop (for-each loop) in Java. Provide its syntax and discuss its advantages and limitations.

  3. Question 3 of 20

    Define an Array in Java. Explain how to declare, instantiate, and initialize a one-dimensional array.

  4. Question 4 of 20

    What are Multi-dimensional Arrays in Java? How are they stored in memory? Write a code snippet to print a 2D array in matrix format.

  5. Question 5 of 20

    Explain the concept of Variable Arguments (Varargs) in Java. How is it defined in a method signature?

  6. Question 6 of 20

    What is an Enumeration (Enum) in Java? How does it differ from a standard class? Provide an example of an Enum used in a switch statement.

  7. Question 7 of 20

    Define Class and Object. Explain the relationship between them and how an object is created in Java.

  8. Question 8 of 20

    What is a Constructor? How does it differ from a regular method? Explain Default and Parameterized constructors.

  9. Question 9 of 20

    Explain Method Overloading with an example. What are the rules for overloading a method?

  10. Question 10 of 20

    Describe the usage of the this keyword in Java with appropriate examples for each use case.

  11. Question 11 of 20

    What are Initializer Blocks? Distinguish between Static Initializer Blocks and Instance Initializer Blocks regarding their execution time.

  12. Question 12 of 20

    Explain Constructor Overloading. How can one constructor call another constructor within the same class?

  13. Question 13 of 20

    Discuss the String class in Java. Why are Strings called Immutable? Explain the concept of the String Constant Pool.

  14. Question 14 of 20

    Compare String and StringBuilder classes. When should you use StringBuilder over String?

  15. Question 15 of 20

    List and explain any five important methods of the String class with examples.

  16. Question 16 of 20

    Write a Java program to define a class Rectangle with fields length and width. Include a constructor to initialize these fields and a method area() to return the area. Instantiate the class and print the area.

  17. Question 17 of 20

    How does the StringBuilder class handle capacity? Explain the append() and insert() methods.

  18. Question 18 of 20

    What is a Jagged Array? How do you declare and initialize a jagged array in Java? Provide a diagrammatic representation description or code.

  19. Question 19 of 20

    Explain the mechanics of the for loop flow. How can you create an Infinite Loop using the for syntax?

  20. Question 20 of 20

    Discuss Anonymous Arrays in Java. When are they useful? Give an example.

That's unit 2

Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.