C# for Java Programmers

Chapter 6: Object-Oriented Programming

Introduction

In the last chapter, you learned about C# objects and classes. As you know, there is more to object-oriented programming (OOP) than just classes and objects. This chapter will explain most of the remaining OOP concepts that you will need to know. You will learn about inheritance, polymorphism, inner classes, and interfaces.

The chapter will begin by discussing the C# inheritance model. Inheritance is the technique of deriving new classes from existing classes. Next, you will be introduced to the concept of polymorphism, which allows for method overriding. In that section, you will learn about virtual methods and versioning with the new and override keywords, which is a feature of C# that is not found in Java.

The next part of the chapter will describe C# s support for inner classes. The chapter will wrap up by discussing interfaces. Interfaces are a way for dealing with the common situation of wanting an object to derive behavior from two different parents, sometimes referred to as multiple inheritance.

Inheritance

C# s inheritance model is very similar to Java, with syntax being the only major difference. To start off, let s review the theory behind this concept.

Inheritance is a relationship between classes. In this relationship, a child class inherits the members and methods of a parent class. Inheritance is an important part of both the C# and Java object models. In both Java and C# all classes are derived from a common base class. Java classes all subclass java.lang.Object, and C#...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Programming Languages
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.