Tuesday, November 23, 2010

Semantic Telephonic and Face To Face


Telephonic

Oops
  1. what is runtime polymorphism?
Run time Polymorphism
  • Run time Polymorphism also known as method overriding
  • Method overriding means having two or more methods with the same name , same signature but with different implementation

2. Can you achieve runtime polymorphism in Interfaces?

No...

interface AAAA
{
void BaseIntMethod();
}
interface BBBB:AAAA
{
void BaseIntMethod();
}

The above code will compile but it gives a warning message like
'BBBB.BaseIntMethod()' hides inherited member 'AAAA.BaseIntMethod()'. Use the new keyword if hiding was intended.


3) suppose there is ClassA with virtual method AAA() and ClassB is inheritted from ClassA and override the method AAA().
ClassA Obj = new ClassB().
By using Obj, which method can be called? method in ClassA or method in ClassB?

public class AAAA
{
public virtual void MethodAAA()
{
MessageBox.Show("Method in AAA");
}
}
public class BBBB:AAAA
{
public override void MethodAAA()
{
MessageBox.Show("Method in BBB");
}
}

AAAA Obj = new BBBB();
Obj.MethodAAA();

OutPut: “Method in BBB”

public class AAAA
{
public virtual void MethodAAA()
{
MessageBox.Show("Method in AAA");
}
public void AnotherMethodInAAA()
{
}
}
public class BBBB:AAAA
{
public override void MethodAAA()
{
MessageBox.Show("Method in BBB");
}
public void AnotherMethodInBBB()
{

}
}

CASE #1

Usage of above code and behaviour of the Object.
Observe in this scenario you are unable to call normal method in Class BBBB. I.e: AnotherMethodInBBB()

CASE #2
Here MethodAAA() is the overide method in Class BBBB.

4)Can we override methods in interfaces?

Yes..the following code works fine..

interface Iinterface
{
void Imethod();
}

public class AAAA : Iinterface
{
public virtual void Imethod()
{
}
}
public class BBBB : AAAA
{
public override void Imethod()
{
}
}

  1. what is garbage collector?
Garbage collector manages the allocation and release of memory for your application.

Each time you create a new object, the common language runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory. The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.


  1. what is generic collections?
List is a generic collection. Lists are dynamic arrays in the C# language. They can grow as needed when you add elements.They are considered generics and constructed types.


  1. what are anonymous methods?
An anonymous method is a method without a name - which is why it is called anonymous.You don't declare anonymous methods like regular methods. Instead they get hooked up directly to events. Because you can hook an anonymous method up to an event directly, couple of the steps of working with delegates can be removed. An anonymous method uses the keyword, delegate, instead of a method name.

 public Form1()
    {
        Button btnHello = new Button();
        btnHello.Text = "Hello";

        btnHello.Click +=
            delegate //anonymous method
            {
                MessageBox.Show("Hello");
            };

        Controls.Add(btnHello);
    }
  1. what is delegate? how it can be used?
A delegate is a type-safe object that can point to another method (or possibly multiple methods) in the application, which can be invoked at later time.

public class MyClass
{
public static int AddNos(int x, int y)
{
return x + y;
}
public static int MultiplyNos(int a, int b)
{
return a * b;
}
}

//Declaring a Delegate...
public delegate int MyAddDelegate(int x1,int x2);

Using a delegate...

private void button1_Click(object sender, EventArgs e)
{
//Create a Delegate Object and Points it to a method...

MyAddDelegate ObjDel = new MyAddDelegate(MyClass.AddNos);

//Calling method using Delegate Object......

int iAdResult = ObjDel(25, 25);

MessageBox.Show(iAdResult.ToString());

MyAddDelegate ObjDlg = new MyAddDelegate(MyClass.MultiplyNos);
int iMulResult = ObjDlg(25, 25);
MessageBox.Show(iMulResult.ToString());
}

Multicast delegates....

public class MyClass
{
public static void AddNos(int x, int y)
{
MessageBox.Show((x + y).ToString());
}
public static void MultiplyNos(int a, int b)
{
MessageBox.Show((a*b).ToString());
}
}
//Declaring a Multicast Delegate...
public delegate void MyDelegate(int x1,int x2);

//Using Multicast delegate...
private void button1_Click(object sender, EventArgs e)
{
//Create a Delegate Object and Points it to a method...
MyDelegate ObjDel = new MyDelegate(MyClass.MultiplyNos);

//Adding another method to the Same delegate Object....
ObjDel += new MyDelegate(MyClass.AddNos);
//Calling the two methods using delegate..
ObjDel(25, 25);

//Removing one method from delegate...
ObjDel -= new MyDelegate(MyClass.AddNos);
ObjDel(12, 12);
}

OutPut: 625,50,144

Note:The Multicast delegate here contain methods that return void, if you want to create a multicast delegate with return type you will get the return type of the last method in the invocation list.

  1. what is an event? how it can be handled?
public class EventClass
{
//Declaring a Delegate...
public delegate void MyDelegate(int x, int y);

//Declare an Event of Type MyDelegate..
public event MyDelegate MyEvent;

public void AddMethod(int a, int b)
{
MessageBox.Show("Adding of given Nos" + " " + (a + b).ToString());
}

public void RaiseEvent(int x1, int x2)
{
if (MyEvent != null)
MyEvent(x1, x2);
}
}

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
EventClass ObjCls = new EventClass();
//Create a delegate object which holds the method...
EventClass.MyDelegate ObjDel = new EventClass.MyDelegate(ObjCls.AddMethod);

ObjCls.MyEvent += ObjDel;

ObjCls.RaiseEvent(12, 15);
}
}

  1. what is serialization? Types of serialization?
Converting objects into stream of bytes.

Binary Serialization:

using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace BinarySerilization
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
MyClass Obj = new MyClass();
Obj.sAuthor = "Sekhar";
Obj.sPublisher = "McGrawHill";
Obj.sBookName = "DotNetFundas";

Obj.SerializeObject(@"C:/123.txt");

MyClass MyObj = Obj.DeSerializeObject(@"C:\123.txt");
MessageBox.Show(MyObj.sAuthor);
MessageBox.Show(MyObj.sPublisher);
MessageBox.Show(MyObj.sBookName);

}
}

[Serializable()]
public class MyClass:ISerializable
{
public MyClass()
{
}

public string sAuthor;
public string sPublisher;
public string sBookName;

//Implement method in Iserializable for placing object stream into local disc...
public void GetObjectData(SerializationInfo sInfo, StreamingContext sStrmCntxt)
{
sInfo.AddValue("Author", sAuthor);
sInfo.AddValue("Publisher", sPublisher);
sInfo.AddValue("Book", sBookName);
}

//Override constructor to get an object from stream saved in the local disc...
public MyClass(SerializationInfo sInfo, StreamingContext sStrmCntxt)
{
sAuthor = (string)sInfo.GetValue("Author", typeof(string));
sPublisher = (string)sInfo.GetValue("Publisher", typeof(string));
sBookName = (string)sInfo.GetValue("Book", typeof(string));
}

//method for serializing object...
public void SerializeObject(string sFileName)
{
FileStream fs = new FileStream(sFileName, FileMode.CreateNew, FileAccess.ReadWrite);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, this);//form here control goes to GetObjectData() method to collect serialization info...
fs.Close();
}

//method for Deserializing object....
public MyClass DeSerializeObject(string sFileName)
{
FileStream fs = new FileStream(sFileName, FileMode.Open, FileAccess.Read);
BinaryFormatter bf = new BinaryFormatter();
MyClass Obj = (MyClass)bf.Deserialize(fs);//from here control goes to Overloaded Constructor MyClass()...
fs.Close();
return Obj;
}
}
}

XML Serialization

[XmlRoot("Class_Person")]
public class Person
{

private string _Name;
private int _Age;

[XmlElement("Prop_Name")]
public string Name
{
get {return _Name;}
set{_Name=value; }
}

[XmlElement("Prop_Age")]
public int Age
{
get { return _Age; }
set { _Age = value; }
}
}

private void button1_Click(object sender, EventArgs e)
{
//Serializing the object...
XmlSerializer XmlSer = new XmlSerializer(typeof(Person));

StreamWriter strWrt = new StreamWriter(@"C:\123.xml");
Person ObjPer = new Person();
ObjPer.Name = "Sekhar Peddagopu";
ObjPer.Age = 27;

XmlSer.Serialize(strWrt, ObjPer);

//Deserializing the object...
XmlSerializer XmlSerial = new XmlSerializer(typeof(Person));
StreamReader strRdr = new StreamReader(@"C:\123.xml");
Person AnotherObj = (Person)XmlSerial.Deserialize(strRdr);

MessageBox.Show("Name of Person" + AnotherObj.Name.ToString() + "___" + "Age:" + AnotherObj.Age.ToString());

}


Asp.net

1) what is client server mechanism works in asp.net and window apps?

2) what is session? how session is managed by webserver? if session is outproc then what is the seralization done in that case? How state server manage session? How state server used?

3) How seesion is manage when session mode is outproc?

4) what is webservice? how it is used in application? what proxy can contain?

5) what is xsd?

6) What is styles and theme?

Sql server

1) Types of index? How storage is done in both?

2) Difference between SP and Fn?

  1. Difference between Char, VarChar and nVarChar?
  • Nvarchar stores Unicode data (two bytes for each character) while varchar stores single-byte character data.
  • nvarchar requires twice the storage space as varchar.
  • Main reason for preferring nvarchar over varchar would be internationalization (i.e. storing strings in other languages).
2nd Round F to F

1) How do you maintain your session in your e-commerce application? Is it Inproc or outproc?

2) Did you write any javascript in your code? Why do you make validations using javascript without using asp.net validation controls.

3) How do you pass user name and password to server from aspx page?

4) What is serialization and why do you need it? How do you serialize objects?

5) what is Ienumerable interface?

6) How do you type cast user defined data types? Have ever heard 'is' and 'as' keywords?

7) Have you ever create index? What is its purpose?

8) what compile code can contain? what CLR does?

9) What components can contain? how do you use components in your code?

10) How did you implement Ooops in your project?

11) In which scenarios Interface and Abstract class can be used?

12) How do you copy an object? How do you clone object?

13) What is cursor?

  1. What is temp table?
Temporary tables provide a way to organize data derived from queries into new tables, which can themselves be queried repeatedly over the lifetime of a MySQL user session. It is also used to hold the results of a called stored procedure .

The syntax to create a temporary table is exactly same as the syntax to create a normal table. But the difference is the table name is prefixed with '#' (pound). By looking at the prefix '#' the sql server understands that it is a temporary table. The following code demonstrates how to create a temporary variable.

CREATE TABLE #Customer
(
CustomerID int identity(1,1),
CustomerName varchar(100),
CompanyName varchar(100),
Address varchar(250)
)
It is almost similar to normal table with very few exceptions. The scope of the temp table is the current connection session. This table is automatically dropped when the connection session is closed. Foreign key relations cannot be applied to temp tables. When you create a temporary table it will be created in tempdb

  1. what is the difference in .net frameword 2.0 and .net framewor 3.5?


  1. Is CLR versions same for 2.0 and 3.5?

Yes...CLR version for 2.0 and 3.5 is same.

17) what is Linq? when you can use Linq in code?

18) In which case you use function and stored procedure?

19) Suppose two persons accessing one bank a/c same time. Both are shown by same balance? Using Dataset, how do you avoid concurrency exception?

20) what is basic difference between xml webservice and wcf?

21) what is runtime polymorphism?

22) what is difference between server.transfer and response.redirect?

23) Difference between dataset and datareader?

24) How do you contorl finalizer?

25) where is the view state available?

26) Where can you use functions?

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.