Department of Computer Applications: Marathwada Institute of Technology, Aurangabad

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

G.S.

Mandal’s

Marathwada Institute of Technology,Aurangabad


Department of Computer Applications
Assignment

Class: FY B.VOC
Sub: Oops With Java (MCQ)
Sub Teacher: Dr. Madhuri Joshi

1
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
1) Which of these access specifiers can be used for an interface?
A. Public
B. Protected
C. private
D. Any of the above

2) What is wrong with below source code?


interface IShape {
void f1();

void f2();

void f3();
}

class Circle implements IShape {

public void f1() {


}
}

A. Compile time error


B. Run time error
C. Source code is OK

3) The fields in an interface are implicitly specified as


A. Static
B. Protected
C. Private
D. Static and final

2
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
4) What is output of the below java code?
interface X
{
int i = 5;
}

class Y implements X
{
void f()
{
i = 10;
System.out.println("i="+i);

}
}
public class Main {

public static void main(String[] args) {

Y obj = new Y();


obj.f();
}
}

A. 0
B. 5
C. 10
D. Compiler error

3
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
5) Which is correct option about java interface?
A. Interface is used to achieve multiple inheritance in java
B. Object of an interface cannot be created.
C. An interface can extend another interface.
D. All of the above

6) False statement about Java interface


A. It is used to achieve abstraction and multiple inheritance in
Java.
B. It can be instantiated, means, we can create an object of an
interface.
C. There can be only abstract methods in the interface not method
body.
D. All are correct.

7) What is output of the below java program?


interface IShape {
void f();
}

class Circle implements IShape {

public void f() {


System.out.println("Interface");
}
public void c() {
System.out.println("class");
}
}

public class Main {

public static void main(String[] args) {


4
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
IShape obj = new Circle();
obj.f();
}
}

A. Interface
B. Class
C. Compiler error

8) Java interface is used to


A. Implement behaviour of multiple inheritance
B. Achieve abstraction
C. achieve loos coupling
D. All of the above

9) Which of the following is true about interfaces in java?


Consider an interface that has 5 methods in it.
A. A class can implement few methods which is required for the
class.
B. The class must implement all the five methods.

10) Which is true statements about an interface in java?


A. An interface can extend another interface
B. We can create object of an interface in java
C. An interface can have constructor
D. None

5
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
11) What is output of below java program?
interface X
{
void f();
}
interface Y extends X
{
void g();
}

class C implements Y
{
public void f() {
System.out.println("Hello");
}
public void g() {
System.out.println("World");
}
}

public class Main {

public static void main(String[] args) {

C o = new C();
o.f();
o.g();
}
}

A. Hello, World
B. Hello
C. World
6
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
D. Compiler error

12) Which of the following contains only unimplemented methods?


A. Class
B. Abstract class
C. Interface
D. None

13) A class inherits an interface using which keyword?


1. Extends
2. Implements
3. Inherit
4. None

14) What concepts come under Polymorphism in java?


A. Method overloading
B. Constructor overloading
C. Method overriding
D. All the above

15) Which polymorphism behavior do you see in below class?


class Paint {
// all methods have same name
public void Color(int x) {
}

public void Color(int x, int y) {


}

public void Color(int x, int y, int z) {


}
}
7
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
A. Method overloading
B. Constructor overloading
C. Method overriding
D. Run time polymorphism

16) Which polymorphism concept is applied to inheritance relationship in


java programming?
A. Method overloading
B. Constructor overloading
C. Method overriding
D. None

17) Which feature comes under compile time polymorphism?


A. Method overloading
B. Constructor overloading
C. Method overriding
D. Both A and B
E. Bothe A and C

18) In below java code, whose “Car” will be called?


class Father {

public void car() {


System.out.println("Father's Car");
}
}

class Son extends Father {

public void car() {


System.out.println("Son's Car");
8
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
}

9
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
}

public class Sample {

public static void main(String[] args) {

Son john = new Son();


john.car();
}

A. Father’s Car
B. Son’s Car
C. There is an ambiguity, so no one Car
D. Compiler Error

19) Which is runtime polymorphism in java oops?


A. Method overloading
B. Method overriding
C. Constructor overloading
D. None

20) In below java program, the class Circle implements the interface
Shape. Which polymorphism concept has been applied here?
interface Shape {
void area();
}

class Circle implements Shape {

public void area() {

10
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
}

11
FY B.Voc MCQ’s On OOPS with Java Dr. Madhuri Abhijeet Joshi
}
A. Method overloading
B. Method overriding
C. No polymorphism

12
FY B.Voc MCQ’s On OOPS with JAVA Dr. Madhuri Abhijeet Joshi

You might also like