E
INSPIRED BY LE
MANIPAL
ACADEMY of HIGHER EDUCATION
Deemed to be University under Section 1 of the UGC Act, 1956)
Question Paper Report
Question Paper
Marks: 15
Answer all the questions.
1)
2)
3)
4)
5)
28-Nov-2022 11:19:17
ASHRUT ALOK ARORA ..
Logout
MANIPAL ACADEMY OF HIGHER EDUCATION
B.Tech III Semester II Sessional Examination November 2022 OBJECT ORIENTED PROGRAMMING [DSE
2153]
MCQ
Which of these access specifiers can be used for an interface?
public protected private All of these
Which of these keywords is used by a class to use an interface defined previously?
implements import export define
Which of these keywords must be used to monitor for exceptions?
catch try finally throw
Which of these keywords is not a part of exception handling?
try finally thrown
catch
What will be the output of the following code?
class exception_handling
{
public static void main(String args[])
{
try
Back
Duration: 60 mins.
Section Duration: 20 mins
{ System.out.print ("Exception" + " " + 1 / 0); } catch (ArithmeticException e)
{ System.out.print ("handled"); }
}
(0.5)
(0.5)
(0.5)
(0.5)
(0.5)
Exception Exceptionhandled handled No output
6)
Which of these methods of Thread class is used to find out the priority given to a thread?
(0.5)
getPriority getThread Priority thread Priority) priority()
7)
Which function of Thread class is used to check weather current thread being checked is still running?
(0.5)
alive isAlive is Running()
run(
8)
Which of these classes is/are used for input and output operation when working with bytes?
(0.5)
Reader InputStream Writer All of these
9)
Which of the following classes is not related to input and output stream in terms of functioning?
(0.5)
Reader File Writer InputStream
10)
Which of these is a process of writing the state of an object to a byte stream?
(0.5)
Serialization Deserialization Externalization File filter
DESCRIPTIVE
Answer all the questions. 11)
12)
Section Duration: 40 mins
Write a java program to input Registration number, city, average mark, email id of the student, and validate the input
data as per following criteria using exception handling technique:
i. Average mark must be between 0 and 100.
ii. Check for validity of email id (valid if ends with gmail.com or manipal.edu).
The following program is used to copy the content of source.txt into dest.txt. Identify the mistake if there is any, and
suggest your solution.
1 import java.io.*;
2
class CopyFile {
23
public static void main(String[] args) throws IOException { int i;
FileReader file_in = null;
ญ
4
5
6
FileWriter file_out = null;
7
String input_filename = "source.txt";
8
String output_filename = "dest.txt";
—
9
10
11
file_in = new FileReader( input_filename ); file_out = new FileWriter (
output_filename ); do {
(2)
12
i = file_out.read();
13
if(i != -1)
14
file_in.write(i);
15
} while (i != -1);
16
file_in.close();
17
file_out.close();
18
}
19 }
13)
14)
Write a program to read all lines from the file "sample.txt" in class "ReadLine" and store them in string "s1". The
method "process()" searches for string "s2❞ and replaces it with string "s3". The updated string "s1" should be stored
in the file "updated.txt" through method "fileUpdate()". The main class "MainClass” creates objects and calls the
methods to do tasks. Consider suitable exceptions (3) in the program.
Develop a multithreaded application in java to perform array operations as follows:
MainThread: Read input elements from the keyboard and store them in an array, also display the count of odd and
even numbers obtained from the following threads:
Thread-1: Display all the odd numbers present in the array.
(3)
Thread-2: Display all even numbers present in the array.
Note: Create the threads using Runnable interface to perform the above operations.
LM Exam Suite
© 2022 All rights reserved.
Paperless Digital Exams
Top
epm
IP: 45.112.146.85
epCloud 1.5