JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech III OBJECT ORIENTED PROGRAMMING THROUGH JAVA Previous Question Paper (February/March - 2022 - R18)
Answer any five questions
All questions carry equal marks
Main
What is method overloading? Define two methods that have same name but different parameter types. Define two methods in class that have identical method names and parameter profile with different return value types or different modifier.
Answer
Method overloading is a feature in Java that allows a class to have multiple methods with the same name, provided their parameter lists (number, type, or order of arguments) are different. This is a form of compile-time polymorphism.
Example of overloading with different parameter types:
void display(String s) { ... }
Regarding the second part of the query, Java does not support overloading based solely on return type or modifiers. If two methods have the same name and identical parameter profiles, the compiler will throw a compilation error, regardless of whether the return types or access modifiers (like public or private) differ. The method signature in Java is defined strictly by the method name and the parameter list; therefore, the return type is not part of the signature.
What is an array? Write a program that creates and initializes a four integer elements array. Find the sum and average of its value.
Answer
An array is a container object that holds a fixed number of values of a single data type. Once created, the length of an array is established and cannot be changed.
The following program initializes an array of four integers and calculates their sum and average:
public class ArraySum {
public static void main(String[] args) {
int[] numbers = {10, 20, 30, 40};
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
double average = (double) sum / numbers.length;
System.out.println("Sum: " + sum);
System.out.println("Average: " + average);
}
}Write a program to find the inverse of a given matrix.
Answer
Sign in to view the complete answer paper.
What is constructor? Explain the types of constructors are used in Java.
Answer
Sign in to view the complete answer paper.
Explain the process of defining and creating a package with suitable examples.
Answer
Sign in to view the complete answer paper.
Define an interface in java. How are interfaces implemented? How they can be accessed?
Answer
Sign in to view the complete answer paper.
Explain the types of Access specifiers are used in Java and also illustrate with an example.
Answer
Sign in to view the complete answer paper.
What is the use of super and final?
Answer
Sign in to view the complete answer paper.
What is an Exception? List out the keywords for exception handling and write steps to develop user defined exception.
Answer
Sign in to view the complete answer paper.
Write a program that counts number of characters, words, and lines in a file. Use exceptions to check whether the file that is read exists or not.
Answer
Sign in to view the complete answer paper.
What is multithreading? What are the priorities given for multithreading? Explain advantages of multithreading.
Answer
Sign in to view the complete answer paper.
Describe the complete life cycle of a thread with an example.
Answer
Sign in to view the complete answer paper.
Write short notes on event, event source and event listeners.
Answer
Sign in to view the complete answer paper.
Explain about layout manager and different layouts and write an example program to demonstrate layouts.
Answer
Sign in to view the complete answer paper.
How to create an applet? Explain with an example.
Answer
Sign in to view the complete answer paper.
Explain MVC Architecture in detail.
Answer
Sign in to view the complete answer paper.