What is the output of the following program(class inheritance and shadowing)? : Questions « Object Oriented « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Object Oriented » Questions 
6.16.33.What is the output of the following program(class inheritance and shadowing)?
class MainClass extends SuperClass {
  String s = "this";

  public static void main(String[] args) {
    new MainClass();
  }

  MainClass() {
    super.display(s);
  }

  void display(String s) {
    System.out.println("this: " + s);
  }
}

class SuperClass {
  String s = "super";

  void display(String s) {
    System.out.println("super: " + s);
  }
}
6.16.Questions
6.16.1."X extends Y" is correct if and only if X is a class and Y is an interface(True/False)
6.16.2.Answer: interface extends
6.16.3."X extends Y" is correct if and only if X is an interface and Y is a class(True/False)
6.16.4.Answer: class and interface
6.16.5."X extends Y" is correct if X and Y are either both classes or both interfaces(True/False)
6.16.6.Answer: interface hierarchy
6.16.7.Which method names follow the JavaBeans standard?
6.16.8.Answer: JavaBeas naming convention
6.16.9.Which, inserted independently at 'insert code here', will compile?
6.16.10.Answer: method overloading and var-arg
6.16.11.What is the result(enum value)?
6.16.12.Answer: enum value
6.16.13.What is the result when trying to compiling the following code(abstract and interface)?
6.16.14.Answer: abstract and interface
6.16.15.What is the result when trying to compiling the following code(variable name)?
6.16.16.Answer: variable name
6.16.17.What is the result when trying to compiling the following code(array declaration)?
6.16.18.Answer: array declaration
6.16.19.What is the result when trying to compiling the following code(enum definition spot)?
6.16.20.Answer: enum definition spot
6.16.21.What is the result(enum and for loop)?
6.16.22.Answer: enum and for loop
6.16.23.What is the result(static method)?
6.16.24.Answer: static method
6.16.25.Is the following code compilable(subclass and override)?
6.16.26.Answer: subclass and override
6.16.27.Is the following code compilable(subclass and overloading)
6.16.28.Answer: subclass and overloading
6.16.29.Is the following code compilable(override and exception throws statements)?
6.16.30.Answer: override and exception throws statements
6.16.31.What is the output(compare two enum values)?
6.16.32.Answer: compare two enum values
6.16.33.What is the output of the following program(class inheritance and shadowing)?
6.16.34.Answer: class inheritance and shadowing
6.16.35.What is the output of the following program(inner class)?
6.16.36.Answer: using inner class
6.16.37.What is ture for a fully encapsulated class?
6.16.38.Answer: encapsulated class
6.16.39.What is an example of polymorphism?
6.16.40.Answer: polymorphism
6.16.41.Which modifiers may not be used with a top-level class?
6.16.42.Answer: Which modifiers may not be used with a top-level class
6.16.43.The compiler supplies a default constructor if no constructors are provided for a class(True/False).
6.16.44.Answer: default constructor
6.16.45.All constructors have a void return type(True/False).
6.16.46.Answer: return type for constructors
6.16.47.A constructor may throw an exception(True/False).
6.16.48.Answer: constructor and exception
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.