GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 378 of 432    Print  
internal class Piston
{
}
internal class Engine
{
private Pistone[] myPistones = new Piston[4];
public bool Ignition()
{
// some code.....
return;
}
}
public class Car
{
private Engine myEngine = new Engine();
public void Start()
{
// put in keys etc...........
if(myEngine.ignition())
{
//some code ....
}
}
}



What OO concept does the above sample code demonstrate?

1) Delegation
2) Inheritance
3) Composition
4) Polymorphism
5) Combination


  
Total Answers and Comments: 1 Last Update: January 31, 2007     Asked by: vsateeshk 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 31, 2007 02:57:42   #1  
whitevoid        

RE: internal class Piston{}internal ...
Well, if we skip undefined variables (Pistones), and functions (ignition()), this code demonstrate Delegation (myEngine.Ignition() ), and composition (private Piston[] myPistones = new Piston[4]; private Engine myEngine = new Engine(); )
 
Is this answer useful? Yes | No

 Related Questions

All methods marked with the DllImport attribute must be marked as public static extern.  
Latest Answer : It works perfectly.  You can find the dialogue window by using "ALT+Tab" keyRobert  ...

C# does not support an explicit fall through for case blocks. The following code is not legal and will not compile in C#: switch(x){case 0:// do somethingcase 1:// do something in common with 0default:// 
Latest Answer : c# switch allows fall through if and only if in empty case. as long as there is a statement in the case it must  use break or go to to  jump out of the case. ...

The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case 
Latest Answer : Constant : The constants are the one whose value remain same at all the time.it will be used if u want to define something at compile time.Read only....if you don't know value at compile time but u can find that at runtime that time u can use ...

Use a conditional attribute on the method, as shown below: class Debug{[conditional("TRACE")]public void Trace(string s){Console.WriteLine(s);}}class MyClass{public static void Main(){Debug.Trace("hello");}}In 
Latest Answer : if you are using conditinoal attribute then add the name spaceSystem.Diagnostics.ConditionalAttribute ...

What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?
The syntax for calling another constructor is as follows: class B{B(int i){ }}class C : B{C() : base(5) // call base constructor B(5){ }C(int i) : this() // call C(){ }public static void Main() {}}  

If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following 
Latest Answer : If your method does not have any return type then mention void before that method or return 0 ...

C# requires only a single parameter for delegates: the method address. Unlike other languages, where the programmer must specify an object reference and the method to invoke, C# can infer both pieces of 
Latest Answer : This article is good.IntroductionIn this article I am going to share my knowledge on Delegates in C#.This would explain the Delegate using simple examples so that the beginner can understand the same.What is Delegate?Definition:Delegate is type which ...

Here's a quick example of the DllImport attribute in action: using System.Runtime.InteropServices;class C{[DllImport("user32.dll")]public static extern int MessageBoxA(int h, string m, string 
Latest Answer : ans:by using1st:using System.Runtime.InteropServicessecond step[DllImport("user32.dll")]use top of the class ...

I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am passing to it?
You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the following: int i;foo(out i);where foo is declared as follows: [return-type] foo(out int 

The equivalent of inout in C# is ref. , as shown in the following example: public void MyMethod (ref String str1, out String str2) {...}When calling the method, it would be called like this: String s1;String 
Latest Answer : Ans:Answer: The equivalent of inout in C# is ref. , as shown in the following example: public void MyMethod (ref String str1, out String str2) {...}When calling the method, it would be called like this: String s1;String s2;s1 = "Hello";MyMethod(ref s1, ...


 Sponsored Links

 
Related Articles

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Interacting with Other Code

jQuery Interacting with Other Code We learned with our sorting and paging code that we can t treat the various features we write as islands The behaviors we build can interact in sometimes surprising ways; for this reason it is worth revisiting our earlier efforts to examine how they coexist with t
 

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

code

geshibot lang javascript" head This is a JS snippet from Geshi Bot" Replaces the geshi default classes with mambo joomla classes function replaceGeshiWithMamboClasses if document document getElementsByTagName Category
 

C++ Void Pointer and Null Pointer

C Void Pointer and Null Pointer In this C tutorial you will learn about two interesting types of pointers; void pointers and Null Pointer These pointers will be discussed in conjunction with syntax usage and example mosgoogle center Pointer to Void General Syntax void pointer variable; Void is use
 

C++ Pure Virtual Function and Base Class

C Pure Virtual Function and Virtual Base Class In this C tutorial you will learn about pure virtual function declaration of pure virtual function and virtual base class virtual base class and how to implement a virtual base class explained with examples mosgoogle center What is Pure Virtual Function
 

How to Access C++ Class Members

How to Access C Class Members In this C tutorial you will learn how to access Class members dot operator or class member access operator difference between struct and class and  scope resolution operator mosgoogle center It is possible to access the class members after a class is defined an
 

printf() Function Return Value

What is the return value from printf() function? printf function always returns the number of characters printed. Let us understand this with an example: main() { int a=10; printf("%d",printf("%d %d %d", a,a,a)); } In this above program the inner printf i
 

What is the default return value of a function?

The default return value from a function is int. In other words, unless explicitly specified the default return value by compiler would be integer value from function.   When a programmer wants other than integer values to be returned from function then it is essential that the pro
 

exit and return statements

  How does the exit () and return () differ exit () is used to exit the program as a whole. In other words it returns control to the operating system. After exit () all memory and temporary storage areas are all flushed out and control goes out of program. In contrast, the return () stateme
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape