.Net Technical Interview Questions asked in Marlabs, Hyderabad
Hi Friends,
This article is related to the .Net interview questions which are asked in Marlabs software services, Hyderabad.
If anyone is looking forwards to go to Marlabs,please go through these questions with the answers.Hope they will be helpful.
Below are the .net Technical interview Questions asked in Marlabs, Hyderabad
1. Default access specifiers for class member C#?
Ans.
Default modifier for the class – internal
Default modifier for the enum – public
Default modifier for the interface – public
Default modifier for the Method – private
Default modifier for the Field – private
Default modifier for the Properties – private
2. Xaml code is compiled or built on runtime by default?
Ans.
XAML code is compiled by default but can be built on at runtime.
3. Difference between stack panel and wrap panel?
Ans. The main difference between the wrap panel and stack panel is that when we place the controls inside the wrap panel and if there is no space then the controls will come in the next line and they will be wrapped automatically.in case of stack panel, they will not come to next line if no space if remaining.
4. How do you make a class public within an assembly but private outside?
Ans. Make the class as internal type. So that it will be public with in the assembly but will not be accessible outside of the assembly. So it will be private for outside.
5. Apply OOPS concept to improve the code
Class Program
{
Public int GetAreaForRectangle( int Length, int Height)
{
Return Length*Height;
}
Public int GeAreaForCircle( int radius)
{
Return 3.14*rad*rad;
}
Ans.
Create an abstract class and write a single method and then inherit it in the classes as:
public abstract class MyClass
{
public abstract int Area(int param1, int param2=1);
}
Class Rectangle: MyClass
{
public override int Area(int param1, int param2=1)
{
return param1* param2;
}
}
Class Circle: MyClass
{
public override int Area(int param1, int param2=1)
{
return param1* param2;
}
}
To call then, just create the object of the child class and use it;Rectangle r= new Rectangle();
Int area= r.Area(10,20);
Circle c= new Circle();
int cArea = c.Area(10);
6. Provide a better way of writing codereturn "on this day" + DateTime.Now.Day + "in the month of" + DateTime.Now.Month.ToString("MMM") + "in the year" + DateTime.Now.Year;
Ans.var day = DateTime.Now.Day;
var month = DateTime.Now.Month.ToString("MMM");
var year = DateTime.Now.Year;
return "on this day" + day + "in the month of" + month + "in the year" + year;
7. Extend system.DateTime to code Function Get Days in company on DateTime of objects,
For ex: employe.DateofJoin.Getdays in company()
Ans. I think there are asking here for the Linq to add the extra functionality. The extension method needs to be written for the Getdays()..
8.If a database has 100 thousand users, then write an improved code for below,
Select code, Name, Age, Mobile from employee where designation = upper(@user Provided)
Ans.
We can use Index for improving the performance. Check for the indexed column and then use it:Select code, Name, Age, Mobile from employee (Index= ode) where designation = upper(@user Provided)
9. How to have controller check? ( Its a MVC question) var album= this.service.GetAlbum(id);
Ans. The controller name should be the ServiceController and it should have the GetAlbum method. By passing the albumid to get the details of that particular album.
10. How to add validation using data annotation: properties (get; set;)
Ans. Validation can be written as the data annotation in MVC applications. MVC support the Model based validation where the model class will have the validations. In the Model class, we can directly write the data annotations as:
public class Customer
{
[Required]
Public int CustomerID{get;set;}
[Range(1,100)]
Public int Qty(get;set;)
}
11. Create a json structure, give an example for it with syntax explanation.
Ans.
var x={key1:val1; key2:val2;key3:var3}
JSON (java Script Object notation) is mainly used for the data communication in the hetero generous environment where the JSON data will be transferred between the client and servers.
It always takes the key value pair. It can take the data in to the textual format so no need to typecast or convert while sending to the network.
12. This one please answer: write below code in C#
*
***
*****
*******
*********
Ans.
I think this should be simple….Just 2 for loop that's allfor(int i=0;i <5; i++)
{
for(int j=1;j<2i-1;j++)
{
Console.WriteLine(j.ToString());
}
}
Hope the questions and answers will be helpful to all of us.
Thanks Pawan
It will really helpful to all Members. Really good