write code to demonstrate the features of oop use C# programming.
OOPS Concepts
Class: A class is made up of three things :- Name, operations, attributes
Object: combination of variables, functions, and data that performs a set of related activities
Encapsulation: when a group of related methods, properties, and other members are treated as a single object.
Inheritance: the ability to receive (inherit) methods and properties from an existing class.
Polymorphism : when each class implements the same methods in varying ways, but you can still have several classes that can be utilized interchangeably.
Abstraction : process by which a developer/coder hides everything other than the relevant data about an object in order to simplify and increase efficiency.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Code Snippet for Class
Class Example {
/* Fields,
Variables,
Properties
*/
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code Snippet for Object
Class Example {
/* Fields,
Variables,
Properties
*/
}
/* Syntax to create object for Class Example */
Example exampleObject = new Example();
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Inheritance:- Inheritance allows the child class to reuse the property of the parent class. It increases code reusability.
Code Snippet for Inheritance
public class parentclass{
public parentclassmethod()
{
Console.WriteLine("Parent class method");
}
}
public class childclass : parentclass /* child class inherting parent class */
{
public childclassmethod
{
Console.WriteLine("Child class method");
}
}
Class Test
{
static void Main(string[] args)
{
childclass obj = new childclass(); /* creating child class
object to call parent class method */
obj.parentclassmethod();
}
}
}
output
Parent class method
----------------------------------------------------------------------------------------------------------------
Polymorphism :- are of two types
1. Compile Time Polymorphism :- we will declare method with same name but with different parameter/signature
Code snippet
public class ParentClass
{
public void sum(int a, int b) {
Console.WriteLine(a+b);
}
public void sum(int a, int b, int c)
{
Console.WriteLine(a+b+c);
}
}
Class Test
{
static void Main(String[] args)
{
prentclass obj = new ParentClass();
obj.sum(10,20);
obj.sum(10,20,25);
Console.ReadLine();
}
}
}
Output
30
55
2. RunTime Polymorphism:- when we declare a
method with same name and same parameter/signature in different
classes is called run time polymorphism.
Basically, we override a method in the base class by creating a
similar method in the derived class by doing inheritance and by
using virtual and override
keywords.
Code Snippet
public class ParentClass {
public virtual void Display()
{
Console.WriteLine("Parent Class method");
}
public class childclass : ParentClass /* inheriting parent class
*\
{
public override void Display()
{
Console.WriteLine("Child Class method");
}
}
Class Program
{
static void Main(string[] args)
{
ParentClass obj= new childclass();
obj.Display();
Console.ReadLine();
}
}
}
Output
Child Class method
Some code in c ++ and its UML to apply inheritance and get and set methods, the code must be about computers, also applying object-oriented programming I need a code in C++ applying OOP with the topic of computers, then in the code must include the get method returns the variable value, and the set method sets the value.
Define a problem utilizing an efficient sorting algorithm please write code in c++ oop thnx?
3. (a) Outline any four features of Object-Oriented Programming OOP, giving examples in each case. [16 marks] (b) Consider the following code fragments: If a = 10; Evaluate the new value of “b” in the following: (i) b = ++ a; (ii) b = a ++; What value would a and b store in (i) and (ii) after program execution? [4 marks] 4. Create a C++ program that makes use of three arrays; name, mark, grade. The program should accept...
OOP and GUI. This week we take a look at OOP or object oriented programming by looking at the objects in a graphical user interface (GUI). What are GUI objects? What are some of the object that we will be focusing on this week? How are they related to C# classes?
Please use C programming to write a code segment as an answer. Instead of using an while-loop like the following code, please implement a code segment by using a do-while loop. What is the output of the code? #include <stdio.h> void main() { int i = 0; while (i < 5); { printf(“%d ”, ++i); } }
USE C++ Demonstrate how to write an interface for a VEHICLE class using C++. In your interface, demonstrate the following (use comments to explain or for demonstration): -Interface implementation -Multiple interface implementation for a single class -Example of a Diamond Inheritance problem -Polymorphism Explain each term above clearly in the code example and discuss how it is being used USE C++
*MUST BE IN C PROGRAMMING* Demonstrate the ability to think critically Demonstrate the ability to work with strings and chars Demonstrate the ability to design a menu system Write a simple program that allows the user to enter a number between 1 and 1000. The program will then display the Roman numeral equivalent. Allow the user to keep entering numbers for conversion to Roman numerals, or to quit, using a menu system of your own design. Submission Requirements: You are to write...
Describe a programming problem that would require the use of an accumulator write the pseudo code necessary to solve your programming problem.
C Programming -- please use simple coding Write a C program that determines whether a line entered by a user is a palindrome or not. You must demonstrate it as an application of stack (you may use linked list implementation). Hint! Think of the basic property of a stack i.e. LIFO (list-in-first-out).
Please Write in C programming Language For Questions below. write computer code in any programming language or mathematical software to estimate dz using the given method. Then calculate the absolute and relative errors for each. Use exact value p 0.6044 戰,omposite Trapezoidal Rule with N = 6. For Questions below. write computer code in any programming language or mathematical software to estimate dz using the given method. Then calculate the absolute and relative errors for each. Use exact value p...