Object-Oriented Program Design

Practice Questions

Computer Science › Object-Oriented Program Design

Page 1 of 11
10 of 102
1

Design a shell for a class named Dog that has 3 attributes:

  • Does the dog have a tail?
  • Is the dog purebred?
  • A list of strings of definitive features for the dog
2

Design a shell for a class named Dog that has 3 attributes:

  • Does the dog have a tail?
  • Is the dog purebred?
  • A list of strings of definitive features for the dog
3

Design a shell for a class named Dog that has 3 attributes:

  • Does the dog have a tail?
  • Is the dog purebred?
  • A list of strings of definitive features for the dog
4

What does the code print?

class Parent{

final public void show() {

`` System.out.println( "Parent::show() called" );

`` }

}

``

class Child extends Parent {

`` public void show() {

`` System.out.println( "Child::show() called" );

`` }

}

``

public class Main {

`` public static void main(String[] args) {

Parent parent = new Child();

parent .show();

`` }

}

5

What does the code print?

class Parent{

final public void show() {

`` System.out.println( "Parent::show() called" );

`` }

}

``

class Child extends Parent {

`` public void show() {

`` System.out.println( "Child::show() called" );

`` }

}

``

public class Main {

`` public static void main(String[] args) {

Parent parent = new Child();

parent .show();

`` }

}

6

What does the code print?

class Parent{

final public void show() {

`` System.out.println( "Parent::show() called" );

`` }

}

``

class Child extends Parent {

`` public void show() {

`` System.out.println( "Child::show() called" );

`` }

}

``

public class Main {

`` public static void main(String[] args) {

Parent parent = new Child();

parent .show();

`` }

}

7

True or False.

The class BetterMan inherits from the class Man.

public class BetterMan extends Man {

}

8

True or False.

The class BetterMan inherits from the class Man.

public class BetterMan extends Man {

}

9

True or False.

The class BetterMan inherits from the class Man.

public class BetterMan extends Man {

}

10

USING POINTERS

Study the following pseudocode.

**int * var1;**

**int foo = 63;**

**var1 = &foo;**

**var2 = *var1;**

What are the values of var1 and var2?

Page 1 of 11
Return to subject