Wednesday, February 8, 2017

TCS Dot net interview questions




TCS Dot net interview questions for experienced Candidates

One of my friend attended TCS dotnet interview in Bangalore. Below is his Interview experience.

First Round of technical Interview:
Interviewer started with, asking about the personal details, work experience and skill rating on asp.net mvc , c#,Oops and sqlserver.


1.       How does ‘page lifecycle’ of ASP.Net MVC works?

2.       How route table has been created in ASP.NET ASP.Net MVC?
Ans : In short,  Method : "RegisterRoutes()" is used for registering the routes which will be added in "Application_Start()" method of global.asax file, which is fired when the application is loaded or started.

3.       Why to use "{resource}.axd/{*pathInfo}" in routing in ASP.Net MVC?

4.       How can we call a JavaScript function on the change of a Dropdown List in ASP.Net MVC? Asked to write the sample code.


5.       How stage-management concept works in asp.net MVC?
Ans : Interviewer asked about the  uses of Tempdata, Viewbag, ViewData,Sessions.

6.       Does Tempdata hold the data for other request in ASP.Net MVC?

7.       Explain Peek method in Tempdata in ASP.Net MVC?
Ans : Similar to Keep method we have one more method called "Peek" which is used for the same purpose. This method used to read data in Tempdata and it maintains the data for subsequent request.
        string A4str = TempData.Peek("TT").ToString();

8.       How  you can send the result back in JSON format in MVC?

          Ans :  return Json( objCustomer,JsonRequestBehavior.AllowGet);

a9.      What are the action filters available in asp.net mvc?
Ans : An action filter is an attribute that you can apply to a controller action -- or an entire controller -- that modifies the way in which the action is executed. The ASP.NET MVC framework includes several action filters.
· OutputCache – This action filter caches the output of a controller action for a specified amount of time.
· Handle Error – This action filter handles errors raised when a controller action executes.
· Authorize – This action filter enables you to restrict access to a particular user or role

10.  What methods do we need to overrider to implement custom action filter?
Ans :          
1.  OnActionExecuting()                
2.  OnActionExecuted()
3.  OnResultExecuting()
4.  OnResultExecuted
   
11.  Can we use multiple models for a single view? How do you achieve this?
 No, we can't use  multiple models for a single view at a time. But  we can handle this scenario, by creating a view model.

12.  What are the design patterns followed in your project?

Ans :  I said  we followed Repository patter, factory pattern

13.  What is the single ton pattern? In which scenario we can use singleton pattern?

14.  Difference between abstract class and interface?
Sr.No
Abstract Classes
Interface
1
 Abstract class can extend only one class or one abstract class at a time.
 Interface can extend any number of interfaces at a time.
2
Abstract class can extend from a class or from an abstract class.
Interface can have only abstract methods.
3
 Abstract class can have both abstract and concrete methods.
Interface can have only abstract methods.
4
 A class can extend only one abstract class.
 A class can implement any number of interfaces.
5
 Abstract class can have protected public and public abstract methods.
 Interface can have only public abstract methods i.e. by default.
6
 Abstract class can have static, final or static final variable with any access specifier.
Interface can have only static final (constant) variable i.e. by default.
 

15.   Does the abstract class should contain at least one abstract method?
     Ans : No, not required

16.   Why we have interface as we can do everything with abstract class?

17.  How do you maintain security for your application?
Ans: Since, our applications is an intranet, we used windows authentication

18.  How to implement windows authentication? How do you specify roles and permissions to the users?

19.   I have 10 text boxes and a button. The button should be enabled only after I have filled the values in all the textboxes. How do you do that?
    
20.  I have a transaction in the database. Inside that, I have a nested transaction. I have written an insert statement and committed. Now in the outer transaction, if I write rollback, will the committed thing inside the nested transaction will be roll-backed?


 Please share your interview experiences to my Mail id : nsubhash007@gmail.com


7 comments :

  1. send the result back in JSON format in MVC

    Ans:
    public JsonResult getCustomer() {
    Customer obj = new Customer();
    obj.CustomerCode = "1001";
    obj.CustomerName = "Shiv";
    return Json(obj, JsonRequestBehavior.AllowGet);
    }

    ReplyDelete
  2. Ans For 6

    If Tempdata is assigned in the current request then it will be available for the current request and the subsequent request and it depends whether data in TempData read or not. If data in Tempdata is read then it would not be available for the subsequent requests

    ReplyDelete
  3. Ans for 11th Question

    I would say this is good example of using ViewModel here. I would suggest something like -

    Create ViewModel with the composition of the two classes

    public class AddWeightModel
    {
    [Required]
    [DataType(DataType.Text)]
    [Display(Name = "Stone")]
    public Nullable Stone { get; set; }

    [Required]
    [DataType(DataType.Text)]
    [Display(Name = "Pound")]
    public Nullable Pound { get; set; }
    }
    ....
    public partial class Weight
    {
    public int Id { get; set; }
    public string UserId { get; set; }
    public Nullable Stone { get; set; }
    public Nullable Pound { get; set; }
    public Nullable Date { get; set; }
    }
    .....
    public class WeightViewModel
    {
    public IList AddWeightModel { get; set; }
    public Weight Weight { get; set; }
    }

    Then change your view to accept the view models -

    @model WeightViewModel

    Finally modify your controller to cope with the change -

    public ActionResult RecordCard()
    {
    var UserId = User.Identity.GetUserId();
    var weightModel = from m in db.Weights where m.UserId == UserId select m;
    var viewModel = new WeightViewModel
    {
    Weight = weightModel,
    AddWeightModel = new List(){}
    };
    return View(viewModel);
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult RecordCard(WeightViewModel viewModel)
    {
    Weight Model = viewModel.Weight;
    if (ModelState.IsValid)
    {
    using (WebApplication1Entities db = new WebApplication1Entities())
    {
    Weight weight = new Weight();
    weight.UserId = User.Identity.GetUserId();
    weight.Stone = Model.Stone;
    weight.Pound = Model.Pound;
    weight.Date = System.DateTime.Now;

    db.Weights.Add(Model);
    db.SaveChanges();
    }
    }
    return RedirectToAction("RecordCard");
    }

    ReplyDelete
  4. Ans for 19th Quesiton



    $(".txtboxtocheck").change(function(){
    var enablebtn = true;
    $(".txtboxtocheck").each(function(){
    if($(this).val() == '')
    enablebtn = false;
    });

    if(enablebtn)
    $("#butn").attr('disabled',false);
    else
    $("#butn").attr('disabled',true);
    });

    ReplyDelete
  5. This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.

    Back to Original Services Private Limited

    ReplyDelete