Yahoo India Web Search

Search results

  1. Sep 22, 2010 · super is a keyword. It is used inside a sub-class method definition to call a method defined in the superclass. Private methods of the superclass cannot be called. Only public and protected methods can be called by the super keyword. It is also used by class constructors to invoke constructors of its parent class.

  2. Feb 25, 2009 · Whilst when calling super.super.method(), you want to break your own obedience agreement. You just cannot cherry pick from the super class. However, there may happen situations when you feel the need to call super.super.method() - usually a bad design sign, in your code or in the code you inherit !

  3. Apr 13, 2010 · You may call super () with parameters if you want to call a non-default constructor of the superclass, or if the superclass does not have a default constructor. The compiler can only insert the default, no arguments super () constructor. answered Apr 13, 2010 at 20:19. sjohnston.

  4. Jan 15, 2011 · If you want to access the methods in A, extend from A instead of B. When B extends A, it assumes that the underlying A -object won't be manipulated in other ways than how it does it itself. Therefore, by directly accessing the methods of A, you could be breaking how B functions. Imagine, for instance, you have a class that implements a list ...

  5. Nov 4, 2010 · Calling exactly super() is always redundant. It's explicitly doing what would be implicitly done otherwise. That's because if you omit a call to the super constructor, the no-argument super constructor will be invoked automatically anyway.

  6. List<? super Number> means that the reference type of the variable suggests we have a list of Numbers, Objects or Serializables. The reason you can't add an Object, is because the compiler does not know WHICH of these classes are in the generic definition of the actual instantiated object, so it only allows you to pass Number or subtypes of Number, like Double, Integer and so on.

  7. Sep 9, 2013 · Assume you have a class "Child" which inherits from "Parent" which inherits from "Grandparent". <T extends Parent> accepts either Parent or Child while <T super Parent> accepts either Parent or Grandparent. This is the best answer to this question I've ever seen, and ought to be the accepted answer. Simple and works perfectly.

  8. Oct 29, 2013 · 8. It means that the type T must implement Comparable of T or one of its super classes. For example, if A extends B, if you want to use SortedList<A>, A must implement Comparable<A> or Comparable<B>, or in fact just Comparable. This allows the list of A s to be constructed with any valid comparator. answered May 13, 2010 at 14:39.

  9. Jun 28, 2015 · This this refers to the reference to the current instance, also when called like this(arg) it calls the corresponding constructor in the current class. Similarly, when super() is called it calls the corresponding constructor in the super class. They can be called only from a constructor. answered May 22, 2010 at 2:06.

  10. Oct 26, 2010 · 9. this refers to a reference of the current class. super refers to the parent of the current class (which called the super keyword). By doing this, it allows you to access methods/attributes of the current class (including its own private methods/attributes).