Time left:

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


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

A.
B.
C.
D.
E.

2. ► What is a object?

A.
B.
C.
D.
E.

3. ► 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.

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

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
package com.vq.classes;

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

    private VQClassB(int x, int y) {
        this.x = x;
        this.y = y;
    }

    private int x;

    private int y;

    public static void main(String[]args) {
        VQClassB vqb = new VQClassB(20, 10);

        VQClassB.VQClassA vqa = new VQClassB(10, 10).new VQClassA(10);

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

5. ► Following program have compilation error, can you guess root cause of it?

1
2
3
4
5
6
7
8
9
10
11
abstract class VQCourse {
    public String courseName;
    public String courseID;
} public class VirtuQCourseProvide extends VQCourse {

    public static void main(String[]args) {
        VQCourse course1 = new VQCourse();
         course1.courseID = "0001";
         course1.courseName = "JAVA";
         System.out.println(course1.toString());
}}
A.
B.
C.
D.
E.

6. ► 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.

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

A.
B.
C.
D.
E.

8. ► Which statement(s) is true about following program?

1
2
3
4
5
6
7
8
public class VirtuQCourseProvide {

    public static void main(String[]args) {
        String firstName = "VirtuQ";
        String lastName = "Simplifying Education";
        String FullName = firstName + lastName;
        String courseProvider = FullName;
}}
A.
B.
C.
D.
E.

9. ► 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.

10. ► What would be correct output of following program?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class VQCourse {
    public String courseName;
    public int courseID;
} public class VirtuQCourseProvide {

    public static void main(String[]args) {
        VQCourse course1 = new VQCourse();
         course1.courseID = 0001;
         course1.courseName = "0001";

        VQCourse course2 = new VQCourse();
         course2 = course1;

         System.out.println("course1.courseID = " + course1.courseID +
                            ", course2.courseID = " + course2.courseID);
}}
A.
B.
C.
D.
E.


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