JNTU

JNTU MCA 2021 JAVA PROGRAMMING Previous Question Paper (February - 2021 - R13)

MCA | 2021 | III | R13 | February - 2021

Answer PaperPaper Code: 813AQMaximum Marks: 60Time: 2 hours

Answer any five questions

All questions carry equal marks

Main

1

Discuss about for-each loop on Java.

12 marks

Answer

The for-each loop, also known as the enhanced for loop, was introduced in Java 5 to provide a cleaner, more readable syntax for iterating over elements in arrays or collections. It eliminates the need for an explicit index variable or an iterator, thereby reducing the risk of off-by-one errors.

The syntax of the for-each loop is as follows:

for (type variable : array_or_collection) {
    // statements to be executed
}

In this structure, the type must match the data type of the elements stored in the array or collection. During each iteration, the variable is automatically assigned the value of the current element, allowing direct access to the data without needing to reference an index.

Key characteristics and limitations include:

  • It is read-only regarding the collection structure; you cannot modify the collection (e.g., add or remove elements) while iterating, as this will throw a ConcurrentModificationException.
  • It is ideal for scenarios where the index of the element is not required. If the index is necessary for logic (such as updating specific array positions), a traditional for loop remains the appropriate choice.
  • It works with any class that implements the Iterable interface, making it highly versatile for all Java Collection Framework types like ArrayList, HashSet, and LinkedList.

Example usage:

int[] numbers = {10, 20, 30, 40};
for (int num : numbers) {
    System.out.println(num);
}

This approach simplifies code maintenance and improves readability, making it the preferred choice for simple traversal operations in Java applications.

212 marks
a

Describe class and constructor with an example program.

6 marks

Answer

A class is a user-defined blueprint or prototype from which objects are created. It represents a set of properties or methods that are common to all objects of one type. A constructor is a special member method that is invoked automatically when an object of a class is created. It has the same name as the class and does not have a return type.

class Student {
    String name;
    // Constructor
    Student(String n) {
        name = n;
    }
    void display() {
        System.out.println("Name: " + name);
    }
}
public class Main {
    public static void main(String[] args) {
        Student s = new Student("Alice");
        s.display();
    }
}
b

What is method overloading? Explain in detail with example.

6 marks

Answer

Sign in to view the complete answer paper.

3

Define interface? Explain multiple inheritance concept and implement in Java.

12 marks

Answer

Sign in to view the complete answer paper.

412 marks
a

What is run time polymorphism? Implement it in Java with an example.

6 marks

Answer

Sign in to view the complete answer paper.

b

Describe inner class in detail.

6 marks

Answer

Sign in to view the complete answer paper.

512 marks
a

Define Socket and Server Socket classes.

6 marks

Answer

Sign in to view the complete answer paper.

b

Write Java program for client and server communication using Socket.

6 marks

Answer

Sign in to view the complete answer paper.

612 marks
a

Describe File Output and File Input Streams.

6 marks

Answer

Sign in to view the complete answer paper.

b

Write a Java program to copy one file into another file.

6 marks

Answer

Sign in to view the complete answer paper.

7

Write a Java program to handle multiple exceptions in Java.

12 marks

Answer

Sign in to view the complete answer paper.

8

Illustrate and explain keyboard event handling mechanism in Java.

12 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the question paper of JAVA PROGRAMMING from JNTU for MCA 2021 III, February - 2021, R13.

For the solved question paper with answers, switch to the Answer Paper tab.

Other papers in JAVA PROGRAMMING

Loading Question Papers

Fetching data from database...