[go: up one dir, main page]

0% found this document useful (0 votes)
121 views2 pages

Oopj Quiz

This document contains a 10 question quiz about object oriented programming concepts in Java. The questions cover topics like inheritance, polymorphism, interfaces, exceptions, and error handling. Students are asked to provide short answers explaining concepts like how inner classes can access outer class members, declaring a variable argument method, and the order of constructor execution in a class hierarchy.

Uploaded by

kumaraswamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views2 pages

Oopj Quiz

This document contains a 10 question quiz about object oriented programming concepts in Java. The questions cover topics like inheritance, polymorphism, interfaces, exceptions, and error handling. Students are asked to provide short answers explaining concepts like how inner classes can access outer class members, declaring a variable argument method, and the order of constructor execution in a class hierarchy.

Uploaded by

kumaraswamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MALNAD COLLEGE OF ENGINEERING, HASSAN - 573202

(An Autonomous Institution under VTU)


Activity-II: QUIZ Name : Even Semester 2018-19

Branch : Computer Science and Engineering Faculty-in-charge: Shruthi T R Date:


Course Title & Code: Object Oriented Programming with JAVA & CS403 Semester: IV
USN 4 M C I T Max. Marks:10 Time:
1. Answer all questions. Each question carries one mark.
1. Given this class, 6. A class Car and its subclass Yugo both have a
class Test method run() which was written by the programmer as
{ part of the class definition. If junker refers to an object of
int a; type Yugo, what will the following code do?
Test (int i) junker.show();
{
a=i; a) The show() method defined in Yugo will be called
} b) The show() method defined in Car will be called
Write a method called swap() that exchanges the
contents of the objects referred to by two Test
c) The compiler will complain that run() has been
defined twice.
object references.
Ans: d) Overloading will be used to pick which run() is
called.

Ans:

2. An inner class has access to the other members 7. Given the following hierarchy
of its enclosing class. True or False? class Alpha {……
class Beta extends Alpha {….
Ans: class Gamma extends Beta {….
In what order are the constructors for these classes
executed when Gamma object is instantiated?

Ans:

3. Show how to declare a method called sum() that 8. Given two interfaces called Alpha and Beta, show how
takes a variable number of int arguments(use a a class called Myclass specifies that it implements each.
return type of int) Ans:
Ans:
4. Predict the output of following Java Program. 9. Predict the output of following Java program

class Base { class Test extends Exception { }


final public void show() { class demo {
public static void main(String args[]) {
System.out.println("Base::show() called");}}
try {
class Derived extends Base { throw new Test();
}
public void show() { catch(Test t) {
System.out.println("Got the Test Exception");
System.out.println("Derived::show() called"); }} }
class Main { finally {
System.out.println("Inside finally block ");
public static void main(String[] args) { }
}
Base b = new Derived();; }
Ans:
b.show();
}}

Ans:

5. Which of these is a super class of all errors and 10. What is an exception?
exceptions in the Java language? Ans:
a) RunTimeExceptions
b) Throwable
c) Catchable
d) None of the above

Ans:

You might also like