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

1708 questions
810
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
  • 11,036
  • 9
  • 32
  • 40
259
votes
7 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
  • 4,902
  • 4
  • 22
  • 31
196
votes
17 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,963
  • 2
  • 12
  • 4
179
votes
18 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,445
  • 5
  • 22
  • 23
162
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,785
  • 2
  • 24
  • 37
145
votes
12 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
  • 16,593
  • 24
  • 118
  • 215
142
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
  • 4,941
  • 5
  • 23
  • 40
111
votes
2 answers

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
  • 2,200
  • 2
  • 19
  • 27
109
votes
5 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
  • 52,147
  • 13
  • 117
  • 150
87
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
  • 34,517
  • 56
  • 153
  • 221
70
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
  • 947
  • 1
  • 9
  • 20
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
  • 35,055
  • 30
  • 109
  • 163
56
votes
1 answer

Django how to pass custom variables to context to use in custom admin template?

I am extending change_list.html and I need to output a variable defined in settings.py. How do I pass that particular variable into the custom admin template context?
James Lin
  • 25,028
  • 36
  • 133
  • 233
55
votes
2 answers

Extend interface defined in .d.ts file

In my TypeScript project, I use DefinitelyTyped definitions for external js dependencies. Sometimes it might happen that these definitions are outdated. It might also happen than some libraries can add new methods at runtime, like express-validator…
Marco Ancona
  • 2,073
  • 3
  • 22
  • 37
54
votes
3 answers

Scala - extends vs with

I am confused. In my existing project, I am not able to find the difference between extends and with. Could you please help me?
Sri Manga
  • 561
  • 1
  • 5
  • 8
1
2 3
99 100