SlideShare a Scribd company logo
Q1:Classses Concepts?
Class - A user defined complex data type with attributes and operations.
Object - A data instance of the data type defined by a class.
Class variable - An attribute that is shared by all objects of a class. A class variable is also called a
static variable.
Object variable - An attribute that is associated with each individual object of a class. An object
variable is also called an instance variable.
Class method - An operation that requires a class to be implicitly associated with. A class method is
also called static method.
Object method - An operation that requires an object to be implicitly associated with. An object
method is also called an instance method.
In order to use classes and objects, other languages have special syntaxes to define classes,
declare objects, access attributes, and invoke operations. But Perl tries to extend the package
concept to simulate class and extend the reference concept to simulate object.
A class is a blueprint or template or set of instructions to build a specific type of object.
Every object is built from a class. Each class should be designed and programmed to
accomplish one, and only one, thing. (You'll learn more about the Single Responsibility
Principle in Object-oriented programming concepts: Writing classes.) Because each class is
designed to have only a single responsibility, many classes are used to build an entire
application.
Writing a class
A class is a blueprint or template or set of instructions to build a specific type of object. Every object is built
from a class. Remember the chocolate cake example in Object-oriented programming concepts: Objects and
classes? A class is like a recipe. You can’t eat the recipe but you can eat the instance of the recipe that is a
result of following the recipe instructions
Example
. Look at how a chocolate cake class might appear in code:
package cakes {
public class ChocolateCake {
public var numberOfCandles:int;
public function ChocolateCake(){
}
public function putCandlesOnCake():void{
trace("Putting " + numberOfCandles + " candles on the cake.");
}
}
}
In ActionScript 3, all classes must have three pieces: a package statement, a class declaration, and
a class body with a constructor method. Errors will occur if any of these pieces is missing or
improperly coded.
Package statement
package cakes {…}
The first line of a class tells the compiler what package the class belongs to. Packages organize your classes
into groups and are used by the compiler to create a unique, fully qualified name (Review ActionScript 3
fundamentals: Packages for more information about working with packages). In this example, the class is in
the cakes package.
Class declaration
The second line of code in the example above,
public class ChocolateCake {…}
Class body with a constructor method
All of the code that is contained within the curly brackets that follow the class declaration is considered the
class body. Remember, objects are self-contained components that contain properties and methods needed to
make a certain type of data useful. The class body contains those properties and methods. Here is the class
body for the ChocolateCake example:
public var numberOfCandles:int;
public function ChocolateCake(){
}
public function putCandlesOnCake():void{
trace("Putting " + numberOfCandles + " candles on the cake.");
}
OR
Classes (I)
A class is an expanded concept of a data structure: instead of holding only data, it can hold both
data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type,
and an object would be the variable.
Classes are generally declared using the keyword class, with the following format:
class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
} object_names;
Where class_name is a valid identifier for the class, object_names is an optional list of
names for objects of this class. The body of the declaration can contain members, that
can be either data or function declarations, and optionally access specifiers.
All is very similar to the declaration on data structures, except that we can now include
also functions and members, but also this new thing called access specifier. An access
specifier is one of the following three keywords: private, public or protected. These
specifiers modify the access rights that the members following them acquire:
 private members of a class are accessible only from within other members of the same
class or from their friends.
 protected members are accessible from members of their same class and from their
friends, but also from members of their derived classes.
 Finally, public members are accessible from anywhere where the object is visible.
By default, all members of a class declared with the class keyword have private access
for all its members. Therefore, any member that is declared before one other class
specifier automatically has private access.
For example:
inheritance enables new objects to take on the properties of existing objects. A class that is
used as the basis for inheritance is called a superclass or base class. A class that inherits from
a superclass is called a subclass or derived class.
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area (void);
} rect;
Inheritance in Visual Basic
Inheritance lets you write and debug a class one time and then reuse that code as the
basis of new classes. Inheritance also lets you use inheritance-based polymorphism,
which is the ability to define classes that can be used interchangeably by client code at
run time, but with functionally different, yet identically named methods or properties.
What Is Inheritance?
Recall that classes contain fields, properties, events, and methods. Inheritance implies at least two classes:
one class plays the role of parent and the second class plays the role of child. (Occasionally we refer to sibling
classes, those descended from the same parent. Seldom do we refer to a grandparent; generally when we
discuss any ancestor beyond an immediate parent, we use the term ancestor.)
Inheritance Modifiers
Visual Basic introduces the following class-level statements and modifiers to support inheritance:
 Inherits statement — Specifies the base class.
 NotInheritable modifier — Prevents programmers from using the class as a base class.
 MustInherit modifier — Specifies that the class is intended for use as a base class only. Instances
of MustInherit classes cannot be created directly; they can only be created as base class
instances of a derived class. (Other programming languages, such as C++ and C#, use the
term abstract class to describe such a class.)
Example of Inheritance
The simplestinheritance relationship.
Public Class Parent
End Class
Public Class Child
Inherits Parent
End Class
Multiple interface inheritance is supported in Visual Basic .NET.
Public Interface I1
End Interface
Public Interface I2
End Interface
Public Interface I3
Inherits I1, I2
End Interface
Polymorphism
Question and answer Programming
Types of Polymorphism
Static Polymorphism:
 The mechanism of linking a function with an object during compile
time is called early binding. It is also called static binding.
Dynamic Polymorphism:
 C# allows you to create abstract classes that are used to provide
partial class implementation of an interface. Implementation is
completed when a derived class inherits from it.
Polymorphism in VB.NET
Polymorphism is the concept that different objects have different implementations of the same characteristic.
For example, consider two objects, one representing a Porsche 911 and the other a Toyota Corolla. They are
both cars; that is, they both derive from the Car class, and they both have a drive method, but the
implementations of the methods could be drastically different.
Polymorphism sounds a great deal like encapsulation, but it is different. Encapsulation has to do with hiding the
internal implementation of an object. Polymorphism has to do with multiple classes having the same interface.
Real World Exapmles
Example 1
A teacher behaves students.
A teacher behaves his/her seniors.
Here teacher is an object but the attitude is different in different situations.
Example 2
A person behaves the son in a house at the same time that the person behaves an employee in an office.
PolymorphismExample.java
public class PolymorphismExample {
public static void main(String[] args) {
Car car = new Car();
Car f = new Ford();
Car h = new Honda();
car.move();
f.move();
h.move();
}
}
Exception Handling
Exception handling is the process of responding to exceptions when
a computer program runs. An exception occurs when an unexpected
event happens that requires special processing. Examples include
a user providing abnormal input, a file systemerror being encountered
when trying to read or write a file, or a program attempting to divide
by zero.
Exception handling attempts to gracefully handle these situations so that a
program (or worse, an entire system) does not crash. Exception handling
can be performed at both the software (as part of the program itself) and
hardware levels (using mechanisms built into the design of the CPU).
Example of exception handling in JavaScript
try {
console.log(test);
} catch (err) {
console.log("Error encountered: " + err);
console.log("Continuing with the rest of our program…");
}
Question and answer Programming
What is Foreach loop?
The foreach loop in C# executes a block of code on each element in an array or a
collection of items. The foreach loop is useful for traversing each items in an array
or a collection of items and displayed one by one.
For each (or foreach) is a control flow statement for traversing items in a collection. Foreach is
usually used in place of a standard forstatement. Unlike other for loop constructs, however, foreach
loops[1]
usually maintain no explicit counter: they essentially say "do this to everything in this set",
rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read.
In object-oriented languages an iterator, even if implicit, is often used as the means of traversal.
The foreach statement in some languages has some defined order, processing each item in the
collection from the first to the last. The foreach statement in many other languages does not have
any particular order, especially array programming languages, in order to support loop
optimization in general and in particular to allow vector processing to process some or all of the
items in the collection simultaneously.
Syntax
foreach (string name in arr)
{
}
Example:
namespace foreach_loop
{
class Program
{
static void Main(string[] args)
{
string[] arr = new string[5]; // declaring array
//Storing value in array element
arr[0] = "Steven";
arr[1] = "Clark";
arr[2] = "Mark";
arr[3] = "Thompson";
arr[4] = "John";
//retrieving value using foreach loop
foreach (string name in arr)
{
Console.WriteLine("Hello " + name);
}
Console.ReadLine();
}
}
}
What is Arrays?
An array is a collection of variables of the same type that are
referred to by a common name
arrays can have one or more dimensions, although the one-
dimensional array is the
most common
 Arrays are collection of data that belong to similar data type
 Arrays are collection of homogeneous data
 Array elements can be accessed by its position in the array called
as index
 Array index starts with zero
 The last index in an array is num – 1 where num is the no of
elements in a array
 int a[5] is an array that stores 5 integers
 a[0] is the first element where as a[4] is the fifth element
 We can also have arrays with more than one dimension
 float a[5][5] is a two dimensional array. It can store 5x5 = 25
floating point numbers
 The bounds are a[0][0] to a[4][4]
Example
 Arrays are using for store similar data types grouping as a single unit. We can access
Array elements by its numeric index. The array indexes start at zero. The default value
of numeric array elements are set to zero, and reference elements are set to null .
Declaring and Initializing an integer Array
 int[] array= new int[4];
array[0] = 10;
array[1] = 20;
array[2] = 30;
array[3] = 40;
 In the abovecode we declare an Integer Array of four elements and
assign the value to array index . That means we assign values to array
index 0 - 4.
GUI Basic Components
GUI is a A program interface that takes advantage of the computer'sgraphics capabilities to
make the program easier to use. Well-designed graphical user interfaces can free the user from
learning complex command languages. On the other hand, many users find that they work more
effectively with a command-driven interface, especially if they already know the command
language.
Basic Components of a GUI
Graphical user interfaces, such as Microsoft Windows and the one used by the Apple
Macintosh, feature the following basic components:
 Pointer: A symbol that appears on the display screen and that you move
to select objects and commands. Usually, the pointer appears as a small angled
arrow. Text -processing applications, however, use an I-beam pointer that is shaped like
a capital I.
 Pointing device: A device, such as a mouse or trackball, that enables you to select
objects on the display screen.
 Icons: Small pictures that represent commands, files, or windows. By moving the
pointer to the icon and pressing a mouse button, you can execute a command
or convert the icon into a window. You can also move the icons around the display
screen as if they were real objects on your desk.
 Desktop: The area on the display screen where icons are grouped is often referred to
as the desktop because the icons are intended to represent real objects on a real
desktop.
 Windows: You can divide the screen into different areas. In each window, you
can run a different program or display a different file. You can move windows around
the display screen, and change their shape and size at will.
 Menus: Most graphical user interfaces let you execute commands by selecting a
choice from a menu.
In addition to their visual components, graphical user interfaces also make it easier to
move data from one application to another. A true GUI includes standard formats for
representing text and graphics. Because the formats are well-defined, different
programs that run under a common GUI can share data. This makes it possible, for
example, to copy a graph created by a spreadsheet program into a document created
by a word processor.
Many DOS programs include some features of GUIs, such as menus, but are
not graphics based. Such interfaces are sometimes called graphical character-
based user interfaces to distinguish them from true GUIs.
Standard Controls:
Controls are added to the Form from the Toolbox. Each control has a set of properties, and a set
of event procedures associated with it. The following lists the control, reading left to right, top
to bottom as they appear in the standard Toolbox.
1. Pointer.
2. PictureBox Control.
3. Label Control.
4. TextBox Control.
5. Frame Control.
6. CommandButton Control.
7. CheckBox Control.
8. OptionButton Control.
9. ComboBox Control.
10.ListBox Control.
11.Horizontal and Vertical Scroll bars.
12.Timer Control.
13.DriveListBox, DirListBox, and FileListBox.
14.Shape Control.
15.Line Control.
16.Image Control.
17.Data Control.
18.Object Linkking and Embedding (OLE) Control.
Database Case Study
#ERD design
#Normalization
#implementation
#Data dictionary

More Related Content

PPT
Unit 4 Java
PPTX
Class, object and inheritance in python
PPT
Oops in Java
PPTX
Classes, objects in JAVA
PPTX
DOCX
JAVA Notes - All major concepts covered with examples
DOCX
Introduction to object oriented programming concepts
PDF
Object Oriented Programming using JAVA Notes
Unit 4 Java
Class, object and inheritance in python
Oops in Java
Classes, objects in JAVA
JAVA Notes - All major concepts covered with examples
Introduction to object oriented programming concepts
Object Oriented Programming using JAVA Notes

What's hot (20)

PPTX
Object Oriented Programming with C#
PPTX
Opp concept in c++
ODP
OOP java
PPTX
Java basics
PPTX
oops concept in java | object oriented programming in java
PPTX
Object Oriented Programming in Python
PPTX
Introduction to OOP(in java) BY Govind Singh
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
Object Oriented Programing JAVA presentaion
PPTX
Inheritance and Polymorphism Java
PPTX
OOPS Characteristics (With Examples in PHP)
PPTX
Pi j3.2 polymorphism
PPTX
Object Oriented Programming
PDF
Oops concepts || Object Oriented Programming Concepts in Java
PDF
Object oriented approach in python programming
PDF
Python Programming - VIII. Inheritance and Polymorphism
PPTX
Python – Object Oriented Programming
PPT
Java Notes
PPT
Object Oriented Programming In .Net
Object Oriented Programming with C#
Opp concept in c++
OOP java
Java basics
oops concept in java | object oriented programming in java
Object Oriented Programming in Python
Introduction to OOP(in java) BY Govind Singh
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Object Oriented Programing JAVA presentaion
Inheritance and Polymorphism Java
OOPS Characteristics (With Examples in PHP)
Pi j3.2 polymorphism
Object Oriented Programming
Oops concepts || Object Oriented Programming Concepts in Java
Object oriented approach in python programming
Python Programming - VIII. Inheritance and Polymorphism
Python – Object Oriented Programming
Java Notes
Object Oriented Programming In .Net
Ad

Similar to Question and answer Programming (20)

PPTX
Selenium Training .pptx
DOC
My c++
PPTX
concept of oops
PPTX
Application package
PPT
Use Classes with Object-Oriented Programming in C++.ppt
PPT
Object Oriented Language
PPTX
Php oop (1)
PPT
Introduction to OOP with PHP
PDF
JAVA-PPT'S.pdf
PDF
oblect oriented programming language in java notes .pdf
PPTX
Introduction to Object Oriented Programming
ODP
Ppt of c++ vs c#
DOCX
Java mcq
DOC
Delphi qa
PPT
Unit 1 Java
PPTX
python.pptx
PPTX
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
Selenium Training .pptx
My c++
concept of oops
Application package
Use Classes with Object-Oriented Programming in C++.ppt
Object Oriented Language
Php oop (1)
Introduction to OOP with PHP
JAVA-PPT'S.pdf
oblect oriented programming language in java notes .pdf
Introduction to Object Oriented Programming
Ppt of c++ vs c#
Java mcq
Delphi qa
Unit 1 Java
python.pptx
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
Ad

More from Inocentshuja Ahmad (20)

PDF
Bottom up parser
PPTX
7th lec overview - latest
PPTX
6th lec infrared slides
PPTX
5th lec ofdm
PPTX
3rd lec fcss
PPTX
2nd lec wireless terminologies
PPTX
1st lec generations
PPT
4rth lec dsss
DOCX
Long questions
DOCX
Lecture notes on mobile communication
PPTX
Lecture5 mobile communication_short
PPT
8th lec flow and error control
PDF
Chapter 10:Risk and Refinements In Capital Budgeting
PDF
Chapter 9:Capital Budgeting Techniques
PDF
Chapter 5:Risk and Return
PDF
Email security & threads
PPT
Chapter03 Top Down Design with Function
DOC
File System FAT And NTFS
Bottom up parser
7th lec overview - latest
6th lec infrared slides
5th lec ofdm
3rd lec fcss
2nd lec wireless terminologies
1st lec generations
4rth lec dsss
Long questions
Lecture notes on mobile communication
Lecture5 mobile communication_short
8th lec flow and error control
Chapter 10:Risk and Refinements In Capital Budgeting
Chapter 9:Capital Budgeting Techniques
Chapter 5:Risk and Return
Email security & threads
Chapter03 Top Down Design with Function
File System FAT And NTFS

Recently uploaded (20)

PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
01-Introduction-to-Information-Management.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Insiders guide to clinical Medicine.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Microbial disease of the cardiovascular and lymphatic systems
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Supply Chain Operations Speaking Notes -ICLT Program
01-Introduction-to-Information-Management.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
FourierSeries-QuestionsWithAnswers(Part-A).pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
human mycosis Human fungal infections are called human mycosis..pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
O7-L3 Supply Chain Operations - ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
Final Presentation General Medicine 03-08-2024.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPH.pptx obstetrics and gynecology in nursing

Question and answer Programming

  • 1. Q1:Classses Concepts? Class - A user defined complex data type with attributes and operations. Object - A data instance of the data type defined by a class. Class variable - An attribute that is shared by all objects of a class. A class variable is also called a static variable. Object variable - An attribute that is associated with each individual object of a class. An object variable is also called an instance variable. Class method - An operation that requires a class to be implicitly associated with. A class method is also called static method. Object method - An operation that requires an object to be implicitly associated with. An object method is also called an instance method. In order to use classes and objects, other languages have special syntaxes to define classes, declare objects, access attributes, and invoke operations. But Perl tries to extend the package concept to simulate class and extend the reference concept to simulate object. A class is a blueprint or template or set of instructions to build a specific type of object. Every object is built from a class. Each class should be designed and programmed to accomplish one, and only one, thing. (You'll learn more about the Single Responsibility Principle in Object-oriented programming concepts: Writing classes.) Because each class is designed to have only a single responsibility, many classes are used to build an entire application. Writing a class A class is a blueprint or template or set of instructions to build a specific type of object. Every object is built from a class. Remember the chocolate cake example in Object-oriented programming concepts: Objects and classes? A class is like a recipe. You can’t eat the recipe but you can eat the instance of the recipe that is a result of following the recipe instructions Example . Look at how a chocolate cake class might appear in code: package cakes { public class ChocolateCake { public var numberOfCandles:int; public function ChocolateCake(){ } public function putCandlesOnCake():void{ trace("Putting " + numberOfCandles + " candles on the cake."); } } }
  • 2. In ActionScript 3, all classes must have three pieces: a package statement, a class declaration, and a class body with a constructor method. Errors will occur if any of these pieces is missing or improperly coded. Package statement package cakes {…} The first line of a class tells the compiler what package the class belongs to. Packages organize your classes into groups and are used by the compiler to create a unique, fully qualified name (Review ActionScript 3 fundamentals: Packages for more information about working with packages). In this example, the class is in the cakes package. Class declaration The second line of code in the example above, public class ChocolateCake {…} Class body with a constructor method All of the code that is contained within the curly brackets that follow the class declaration is considered the class body. Remember, objects are self-contained components that contain properties and methods needed to make a certain type of data useful. The class body contains those properties and methods. Here is the class body for the ChocolateCake example: public var numberOfCandles:int; public function ChocolateCake(){ } public function putCandlesOnCake():void{ trace("Putting " + numberOfCandles + " candles on the cake."); } OR Classes (I) A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions. An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable. Classes are generally declared using the keyword class, with the following format: class class_name { access_specifier_1:
  • 3. member1; access_specifier_2: member2; ... } object_names; Where class_name is a valid identifier for the class, object_names is an optional list of names for objects of this class. The body of the declaration can contain members, that can be either data or function declarations, and optionally access specifiers. All is very similar to the declaration on data structures, except that we can now include also functions and members, but also this new thing called access specifier. An access specifier is one of the following three keywords: private, public or protected. These specifiers modify the access rights that the members following them acquire:  private members of a class are accessible only from within other members of the same class or from their friends.  protected members are accessible from members of their same class and from their friends, but also from members of their derived classes.  Finally, public members are accessible from anywhere where the object is visible. By default, all members of a class declared with the class keyword have private access for all its members. Therefore, any member that is declared before one other class specifier automatically has private access. For example: inheritance enables new objects to take on the properties of existing objects. A class that is used as the basis for inheritance is called a superclass or base class. A class that inherits from a superclass is called a subclass or derived class. class CRectangle { int x, y; public: void set_values (int,int); int area (void); } rect; Inheritance in Visual Basic
  • 4. Inheritance lets you write and debug a class one time and then reuse that code as the basis of new classes. Inheritance also lets you use inheritance-based polymorphism, which is the ability to define classes that can be used interchangeably by client code at run time, but with functionally different, yet identically named methods or properties. What Is Inheritance? Recall that classes contain fields, properties, events, and methods. Inheritance implies at least two classes: one class plays the role of parent and the second class plays the role of child. (Occasionally we refer to sibling classes, those descended from the same parent. Seldom do we refer to a grandparent; generally when we discuss any ancestor beyond an immediate parent, we use the term ancestor.) Inheritance Modifiers Visual Basic introduces the following class-level statements and modifiers to support inheritance:  Inherits statement — Specifies the base class.  NotInheritable modifier — Prevents programmers from using the class as a base class.  MustInherit modifier — Specifies that the class is intended for use as a base class only. Instances of MustInherit classes cannot be created directly; they can only be created as base class instances of a derived class. (Other programming languages, such as C++ and C#, use the term abstract class to describe such a class.) Example of Inheritance The simplestinheritance relationship. Public Class Parent End Class
  • 5. Public Class Child Inherits Parent End Class Multiple interface inheritance is supported in Visual Basic .NET. Public Interface I1 End Interface Public Interface I2 End Interface Public Interface I3 Inherits I1, I2 End Interface Polymorphism
  • 7. Types of Polymorphism Static Polymorphism:  The mechanism of linking a function with an object during compile time is called early binding. It is also called static binding. Dynamic Polymorphism:  C# allows you to create abstract classes that are used to provide partial class implementation of an interface. Implementation is completed when a derived class inherits from it. Polymorphism in VB.NET Polymorphism is the concept that different objects have different implementations of the same characteristic. For example, consider two objects, one representing a Porsche 911 and the other a Toyota Corolla. They are both cars; that is, they both derive from the Car class, and they both have a drive method, but the implementations of the methods could be drastically different.
  • 8. Polymorphism sounds a great deal like encapsulation, but it is different. Encapsulation has to do with hiding the internal implementation of an object. Polymorphism has to do with multiple classes having the same interface. Real World Exapmles Example 1 A teacher behaves students. A teacher behaves his/her seniors. Here teacher is an object but the attitude is different in different situations. Example 2 A person behaves the son in a house at the same time that the person behaves an employee in an office. PolymorphismExample.java public class PolymorphismExample { public static void main(String[] args) { Car car = new Car(); Car f = new Ford(); Car h = new Honda(); car.move(); f.move(); h.move(); } }
  • 9. Exception Handling Exception handling is the process of responding to exceptions when a computer program runs. An exception occurs when an unexpected event happens that requires special processing. Examples include a user providing abnormal input, a file systemerror being encountered when trying to read or write a file, or a program attempting to divide by zero. Exception handling attempts to gracefully handle these situations so that a program (or worse, an entire system) does not crash. Exception handling can be performed at both the software (as part of the program itself) and hardware levels (using mechanisms built into the design of the CPU). Example of exception handling in JavaScript try { console.log(test); } catch (err) { console.log("Error encountered: " + err); console.log("Continuing with the rest of our program…"); }
  • 11. What is Foreach loop? The foreach loop in C# executes a block of code on each element in an array or a collection of items. The foreach loop is useful for traversing each items in an array or a collection of items and displayed one by one. For each (or foreach) is a control flow statement for traversing items in a collection. Foreach is usually used in place of a standard forstatement. Unlike other for loop constructs, however, foreach loops[1] usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. In object-oriented languages an iterator, even if implicit, is often used as the means of traversal. The foreach statement in some languages has some defined order, processing each item in the collection from the first to the last. The foreach statement in many other languages does not have any particular order, especially array programming languages, in order to support loop optimization in general and in particular to allow vector processing to process some or all of the items in the collection simultaneously. Syntax foreach (string name in arr) { }
  • 12. Example: namespace foreach_loop { class Program { static void Main(string[] args) { string[] arr = new string[5]; // declaring array //Storing value in array element arr[0] = "Steven"; arr[1] = "Clark"; arr[2] = "Mark"; arr[3] = "Thompson"; arr[4] = "John"; //retrieving value using foreach loop foreach (string name in arr) { Console.WriteLine("Hello " + name); } Console.ReadLine(); } } } What is Arrays? An array is a collection of variables of the same type that are referred to by a common name arrays can have one or more dimensions, although the one-
  • 13. dimensional array is the most common  Arrays are collection of data that belong to similar data type  Arrays are collection of homogeneous data  Array elements can be accessed by its position in the array called as index  Array index starts with zero  The last index in an array is num – 1 where num is the no of elements in a array  int a[5] is an array that stores 5 integers  a[0] is the first element where as a[4] is the fifth element  We can also have arrays with more than one dimension  float a[5][5] is a two dimensional array. It can store 5x5 = 25 floating point numbers  The bounds are a[0][0] to a[4][4] Example  Arrays are using for store similar data types grouping as a single unit. We can access Array elements by its numeric index. The array indexes start at zero. The default value of numeric array elements are set to zero, and reference elements are set to null .
  • 14. Declaring and Initializing an integer Array  int[] array= new int[4]; array[0] = 10; array[1] = 20; array[2] = 30; array[3] = 40;  In the abovecode we declare an Integer Array of four elements and assign the value to array index . That means we assign values to array index 0 - 4. GUI Basic Components GUI is a A program interface that takes advantage of the computer'sgraphics capabilities to make the program easier to use. Well-designed graphical user interfaces can free the user from learning complex command languages. On the other hand, many users find that they work more effectively with a command-driven interface, especially if they already know the command language. Basic Components of a GUI Graphical user interfaces, such as Microsoft Windows and the one used by the Apple Macintosh, feature the following basic components:  Pointer: A symbol that appears on the display screen and that you move to select objects and commands. Usually, the pointer appears as a small angled arrow. Text -processing applications, however, use an I-beam pointer that is shaped like a capital I.  Pointing device: A device, such as a mouse or trackball, that enables you to select objects on the display screen.  Icons: Small pictures that represent commands, files, or windows. By moving the pointer to the icon and pressing a mouse button, you can execute a command or convert the icon into a window. You can also move the icons around the display screen as if they were real objects on your desk.  Desktop: The area on the display screen where icons are grouped is often referred to as the desktop because the icons are intended to represent real objects on a real desktop.  Windows: You can divide the screen into different areas. In each window, you can run a different program or display a different file. You can move windows around the display screen, and change their shape and size at will.
  • 15.  Menus: Most graphical user interfaces let you execute commands by selecting a choice from a menu. In addition to their visual components, graphical user interfaces also make it easier to move data from one application to another. A true GUI includes standard formats for representing text and graphics. Because the formats are well-defined, different programs that run under a common GUI can share data. This makes it possible, for example, to copy a graph created by a spreadsheet program into a document created by a word processor. Many DOS programs include some features of GUIs, such as menus, but are not graphics based. Such interfaces are sometimes called graphical character- based user interfaces to distinguish them from true GUIs. Standard Controls: Controls are added to the Form from the Toolbox. Each control has a set of properties, and a set of event procedures associated with it. The following lists the control, reading left to right, top to bottom as they appear in the standard Toolbox. 1. Pointer. 2. PictureBox Control. 3. Label Control. 4. TextBox Control. 5. Frame Control. 6. CommandButton Control. 7. CheckBox Control. 8. OptionButton Control. 9. ComboBox Control. 10.ListBox Control. 11.Horizontal and Vertical Scroll bars. 12.Timer Control. 13.DriveListBox, DirListBox, and FileListBox. 14.Shape Control. 15.Line Control. 16.Image Control. 17.Data Control. 18.Object Linkking and Embedding (OLE) Control.
  • 16. Database Case Study #ERD design #Normalization #implementation #Data dictionary