Time left:

[All Quizzes] → [Programming With Java] → [Object Oriented Concepts]


1. ► Java provided mechanism where classes can inherit commonly used state and behaviour of other classes.

1
2
3
4
5
package com.vq.inheritance;

public class VQJavaCourse extends VQCourse {
//Some implementation 
}
A.
B.
C.

2. ► Class VQCourse contains declaration about a course, which is inside package com.vq . You are declaring a new class VirtuQCourseProvider where you want to create a object of VQCourse but following program fails to compile. Choose option which eliminates compilation error.

1
2
3
4
public class VirtuQCourseProvide {
    public static void main(String[]args) {
        VQCourse course1 = new VQCourse();
}}
A.
B.
C.
D.
E.

3. ► Select correct statements about class(es).

A.
B.
C.
D.
E.

4. ► Java is an object oriented programming language which where you declare the class which is type of object you just identified. The objects have states and behaviours which are methods in class.

A.
B.
C.
D.
E.

5. ► Select correct option(s) about class Object.

A.
B.
C.
D.
E.

6. ► Which of following statement(s) can result in new object instance creation if executed successfully.

A.
B.
C.
D.
E.

7. ► You only want to declare the behaviour of a certain type without any implemention , you should declare it as interface. In its most common form, an interface is a group of related methods with empty bodies.

1
2
3
4
5
6
7
8
9
package com.vq.inheritance;

public interface VQCourse {

    public void printCourseDetail();

    public void getCoursePrice();

}
A.
B.
C.

8. ► Following is syntax to create a object of class Object. Which statements are true when following statement execute at runtime.

Object obj = new Object();
A.
B.
C.
D.
E.

9. ► What is a object?

A.
B.
C.
D.
E.

10. ► Code below has class VQClassB which inherits another class VQClassA, study following code carefully and choose correct option about output of program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.vq.classes;

class VQClassA {
    public VQClassA(int x) {
        this.x = x;
    } protected int x;
}

public class VQClassB extends VQClassA {
    public VQClassB(int x, int x2, int y) {
        super(x);
        x = x2;
        this.y = y;
    } private VQClassB(int x, int y) {
        super(x);
        this.x = x;
        this.y = y;
    }

    private int x;

    private int y;

    public static void main(String[]args) {
        VQClassA vqa = new VQClassA(10);

        VQClassB vqb = new VQClassB(20, 10);

        vqa = vqb;
        System.out.println(vqa.x + " " + vqb.y);
    }
}
A.
B.
C.
D.
E.


© 2016 VirtuQ™ Education All right reserved. | Terms of Use | Privacy Policy