Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Abstract Class
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public abstract class absParentClass //public class absParentClass { //public abstract int addition(int a, int b) --> Error, cannot declare a body because it is marked abstract //{ // Console.WriteLine(a+b); // return a+b; //} public int addition(int a, int b) { Console.WriteLine(a+b); return a+b; } public int sub(int a, int b) { Console.WriteLine(a-b); return a+b; } public abstract int mul(int a,int b); public abstract int div(int a,int b); } public class absChildClass: absParentClass { //Before Call Parent Class methods addition and sub , We must implement abstract parent methods under child class. public override int mul(int a, int b) { Console.WriteLine(a*b); return a+b; } public override int div(int a, int b) { Console.WriteLine(a/b); return a+b; } } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); //--> Cannot create an instance of the abstract class or interface absParentClass //absParentClass apc=new absParentClass(); //apc.addition(3,5); absChildClass acc=new absChildClass(); acc.addition(2,3); acc.sub(4,1); acc.mul(3,5); acc.div(20,4); //--> Call the all methods with the reference of Parent Abstract Class. absParentClass apc =acc; apc.addition(2,8); apc.sub(4,1); apc.mul(2,3); apc.div(10,2); } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0,19 sec, absolute running time: 0,13 sec, cpu time: 0,12 sec, average memory usage: 15 Mb, average nr of threads: 3, absolute service time: 0,36 sec
edit mode
|
history
|
discussion
Hello, world! 5 3 15 5 10 3 6 5