Questions tagged [extends]

extends is a keyword in several programming languages used to denote implementation inheritance

extends is a keyword in several programming languages which support object-oriented programming used to denote implementation inheritance (as opposed to implements used to denote interface inheritance).

Related

1551 questions
755
votes
19 answers

Implements vs extends: When to use? What's the difference?

Please explain in an easy to understand language or a link to some article.
Saad Masood
  • 10,178
  • 8
  • 29
  • 39
173
votes
15 answers

Extending an Object in Javascript

I am currently transforming from Java to Javascript, and it's a bit hard for me to figure out how to extend objects the way I want it to do. I've seen several people on the internet use a method called extend on object. The code will look like…
Wituz
  • 1,733
  • 2
  • 11
  • 4
164
votes
5 answers

What's the difference between 'extends' and 'implements' in TypeScript

I would like to know what Man and Child have in common and how they differ. class Person { name: string; age: number; } class Child extends Person {} class Man implements Person {}
davejoem
  • 3,310
  • 3
  • 17
  • 29
162
votes
20 answers

Can I extend a class using more than 1 class in PHP?

If I have several classes with functions that I need but want to store separately for organisation, can I extend a class to have both? i.e. class a extends b extends c edit: I know how to extend classes one at a time, but I'm looking for a method to…
atomicharri
  • 2,223
  • 5
  • 21
  • 22
135
votes
7 answers

Can an interface extend multiple interfaces in Java?

Can an interface extend multiple interfaces in Java? This code appears valid in my IDE and it does compile: interface Foo extends Runnable, Set, Comparator { } but I had heard that multiple inheritance was not allowed in Java. Why does…
Prateek
  • 6,239
  • 2
  • 22
  • 37
103
votes
7 answers

How do I call a super constructor in Dart?

How do I call a super constructor in Dart? Is it possible to call named super constructors?
Eduardo Copat
  • 3,991
  • 5
  • 21
  • 39
97
votes
10 answers

Typescript: How to extend two classes?

I want to save my time and reuse common code across classes that extend PIXI classes (a 2d webGl renderer library). Object Interfaces: module Game.Core { export interface IObject {} export interface IManagedObject extends IObject{ …
Vadorequest
  • 12,672
  • 17
  • 87
  • 183
83
votes
4 answers

Extending vs. implementing a pure abstract class in TypeScript

Suppose I have a pure abstract class (that is, an abstract class without any implementation): abstract class A { abstract m(): void; } Like in C# and Java, I can extend the abstract class: class B extends A { m(): void { } } But unlike in…
Michael Liu
  • 44,833
  • 12
  • 104
  • 136
71
votes
4 answers

C#'s equivalent of Java's in generics

In Java, I can do the following: (assume Subclass extends Base): ArrayList aList = new ArrayList(); What is the equivalent in C# .NET? There is no ? extends keyword apparently and this does not work: List aList = new…
Louis Rhys
  • 30,777
  • 53
  • 137
  • 211
69
votes
4 answers

android how to create my own Activity and extend it?

I need to create a base class that extends Activity which does some common tasks in my application and extend my activities from it,in the following form: public BaseActivity extends Activity{....} public SubActivity extends BaseActivity{...} in…
user173488
  • 937
  • 1
  • 8
  • 17
60
votes
3 answers

Javascript extends class

What is the right/best way to extend a javascript class so Class B inherits everything from the class A (class B extends A)?
xpepermint
  • 31,091
  • 29
  • 106
  • 160
57
votes
1 answer

Difference between extending and intersecting interfaces in TypeScript?

Let's say the following type is defined: interface Shape { color: string; } Now, consider the following ways to add additional properties to this type: Extension interface Square extends Shape { sideLength: number; } Intersection type Square =…
Willem-Aart
  • 1,501
  • 1
  • 15
  • 22
49
votes
3 answers

Generics : List is same as List?

I am just trying to understand the extends keyword in Java Generics. List means we can stuff any object in the List which IS A Animal then won't the following also mean the same thing: List Can someone help me know the…
peakit
  • 25,979
  • 25
  • 58
  • 77
48
votes
8 answers

Java why interface extends interface

I am wondering under what circumstances do we extend an interface from an interface? Because, for example interface A{ public void method1(); } interface B extends A{ public void method2(); } class C implements B{ @Override public void…
peter
  • 7,752
  • 16
  • 64
  • 89
48
votes
2 answers

Why "extends" precedes "implements" in class declaration

Why must implement always be written after extend in a class declaration? For example: public class Register extends ActionSupport implements ModelDriven Why can it not be: public class Register implements ModelDriven extends ActionSupport The…
lzjun
  • 651
  • 1
  • 5
  • 8
1
2 3
99 100