Unit 1: Introduction to C# Object Programming Flashcards

1
Q

Object Oriented Programming definition.

A

OOP can be defined as a programming model which is based upon the concept of objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Example OF Object Oriented Programming

A

Examples of an object, can range from physical entities: such as human beings who are described by properties( attributes)
like name and address, to small computer programs such as widgets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are classes?

A

Classes are user defined data types: that act as the blueprint for individual objects, attributes and methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are Objects?

A

Objects are instances of a class created which specifically Define the data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Methods?

A

Methods are functions that are defined inside a class that describe the behaviors of an object.

Each method contains in class definitions stored with a reference to an instance object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Some cartoons contained in an object are called…..?

A

instance methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are Attributes?

A

Attributes represent the state of an object and are defined in the class template.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

objects will have data stored in the……?

A

attribute field, class attributes belong to the class itself .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Methods control the…….

A

Movements or actions of the Object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Abstraction?

A

Abstraction is a process where you show only” relevant” data and “ hide” unnecessary details of an object from the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Encapsulation?

A

Encapsulation is defined as a practice that bind data with the code that manipulates it and keeps the data and the code safe from external inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Inheritance?

A

Inheritance is the mechanism by which an object acquires the same( or all) properties of another object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Polymorphism ?

A

Polymorphism is Ability to process objects differently based on their data type.

In other words objects can have the same name for two methods but their implementation may differ.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A visual representation Encapsulation is….?

A

data security

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A visual representation Inheritance is….?

A

code reusability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A visual representation polymorphism is….?

A

code reusability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

A visual representation abstraction is….?

A

hidden complexity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

the object is found within…?

A

the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

You can use this features to withdraw the money but you never will know what exact actions are operation take place internally in the machine like after card swipe the machine check whether the card is valid or not then the pin will be verified if it is correct then only we can withdraw the money.
WHICH CONCEPT IS USED?

A

Abstraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

a watch you check the time many times in a day but you never need to know what the internal mechanisms of the watch is
WHICH CONCEPT IS USED?.

A

Abstraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

A pet class and a person class
would have a name attribute we can call within getter/setter functions that assign the value

What do you think we should use so that the code knows when the function that is being called and the variable that you are trying to assign?

A

Using encapsulation comes into provide a layer

22
Q

When you are in a classroom , you act like a student when you are in a store, you act like a customer and when you’re at home you act like a daughter or son.

A

The answer is Polyomorphism since it’s different behaviors but one person

23
Q

A child inherits the traits of his/her appearance

A

Answer: inheritance

24
Q

List 3 Benefits of Object-Oriented programming

A

a. Reuse of Code
b. Reduction of errors
C. Faster application development

25
Q

Encapsulation enables objects to be self-contained, making troubleshooting and collaborative development easier.

A

Modularity

26
Q

The code can be reused through inheritance, a team does not have the write the same code multiple times.

A

Reusability

27
Q

Programmers can construct new programs quicker through the use of multiple libraries and reusable code.

A

Productivity

28
Q

Easily Upgradable and Scalable

A

Programmers can implement systems functionalities independently

29
Q

Descriptions of external systems are simple, due to message passing techniques that are used for objects communication.

A

Interface Descriptions

30
Q

Through using encapsulation and abstraction, complex code Is hidden, software maintenance is easier and the internet, Protocols are protected.

A

Security

31
Q

Polymorphism enables a single Function to adapt to the class it is placed in. different objects can also pass through the same interface.

A

Flexibility

32
Q

What are Classes Again?

A

Classes are user-defined data types that represent the state and behavior of an object.

33
Q

What is referred to as the state and behavior?

A

The state represents the properties, and behavior is the action that objects can perform.

34
Q

Classes can be declared using the following access specifiers that limit the accessibility of classes to other classes.
What are they?

A

1.Public
Public class Accounts {

							    }   2.Private  3.Protected  4.Internal  5.protected internal
35
Q

List 4 Points about classes:

A

1.Classes are reference types that hold the object created dynamically in a heat

2.All classes have a base type of System.object

3.The default access modifier of a class is internal

4.The default access modifier of methods and variables is private
directly inside the namespace, declaration of private classes are not alone

36
Q

If there is a need for command line arguments the user must specify the command line arguments in the Main method.
USING………

A

Using System;
Class GFG{
//Main method
Protected static void Main()
}
Console.WriteLine(“Main method”);

37
Q

Public, private, protected, internal and protected internal access modifiers can b e used with the

A

Main() method.

38
Q

The Main method can also have integer return type

A

Returning an integer value from Main()

39
Q

Methods cause the program to obtain…..

A

status information.

40
Q

The value which is returned from the Main() method is treated as the ……

A

exit code for the process.

41
Q

Return type Example

A

Using System;

Class GFG{
//Main method
Static int Main()
{

	Console.WriteLine(“Main method”);

		//for successful execution of code
		Return 0;
	}
42
Q

What does namespace do?

A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it.

A

Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.

43
Q

Using System;

Class GFG{
//Main method
Static int Main()
{

	Console.WeiteLine(“Main method”);

		//for successful execution of code
		Return 0;
	} What does namespace do? 

Using System; (used to define or direct)

namespace MyNamespace
{
public class SampleClass
{
public static void myMethod()
{
Console.WriteLine(“Creating my namespace”);
}
}
}

Namespace MyProgram
{
public class MyClass
{

	public static void Main()
	{
		MyNamespace.SampleClass.myMethod();
	}
} }
A

In the program the namespace is created with MyNamespace and the members are accessed from the Main() method inside MyClass.
The dot(.) operator is used to access the member of the namespace.
In the Main() method, myMethod() method is called using the dot(.) operator.

44
Q

C# Output??

A

Console.WriteLine(“Hello World!”);

45
Q

C# User Input??

A

string userName = Console.ReadLine();

Console.WriteLine(“Enter your age:”);
int age = Console.ReadLine();
Console.WriteLine(“Your age is: “ + age);

46
Q

readline(0 returns a string so if you want it to get something else from the user an int for example you have to convert it
How do you convert user input to a number.

A

Int myNum = Int32.Parse(console.Readline());

47
Q

ToBoolean()

A

Converts a type to a boolean value

48
Q

ToChar()

A

Converts a type char type

49
Q

ToDouble()

A

Converts a type to a double type

50
Q

ToInt16()

A

Converts a type to a 16 bit type

51
Q

ToString()

A

Converts a type to a string