nerdexam
Oracle

1Z0-803 · Question #250

Given: class Sports { int num_players; String name, ground_condition; Sports(int np, String sname, String sground){ num_players = np; name = sname; ground_condition = sground; } } class Cricket extend

The correct answer is A. Cricket() {. not C, not D: call to super must be the first statement in constructor.

Working with Inheritance

Question

Given:

class Sports { int num_players; String name, ground_condition; Sports(int np, String sname, String sground){ num_players = np; name = sname; ground_condition = sground; } } class Cricket extends Sports { int num_umpires; int num_substitutes; Which code fragment can be inserted at line //insert code here to enable the code to compile?

Options

  • ACricket() {
  • BCricket() {
  • CCricket() {
  • DCricket() {

How the community answered

(28 responses)
  • A
    71% (20)
  • B
    4% (1)
  • C
    7% (2)
  • D
    18% (5)

Explanation

not C, not D: call to super must be the first statement in constructor.

Topics

#inheritance#constructors#super keyword#constructor chaining

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice