Translate to your language...

Showing posts with label Properties. Show all posts
Showing posts with label Properties. Show all posts

6 October 2015

Most Interesting Questions in C#, ASP.Net and SQL Server, WCF, ASP.Net MVC

Hello Guys,
In this article, we will see the most interesting questions in Microsoft Technologies like in C#, ASP.Net, Sql Server, WCF services, ASP.Net MVC.
Q 1. I have logged in to the ASP.Net website using my credential for the login page. Now I want that when my session is expired, it should logout the application and show the login page. With that It should also logged out from the Windows and I should use the Windows credentials again to reach to my application again. How do you think it can be done?
Ans. This question is related to the Sessions in ASP.Net where the session time out is configured for the current user. And when the session gets expired, we need to set so that it should automatically come back to login page and user need to enter the credentials again.

Session time can be set as:

Q 2. In .Net Framework, Garbage collector is used for the Automatic Memory Management(to free-up the memory which is no longer used by the resources). There are 2 types of memory- the memory which is created using value types(Stack memory) and the Memory created using Reference Types(Heap Memory). Which of these memory will be disposed by the Garbage Collector?
Ans. Garbage Collector is used to free-up the memory of unreferenced objects, the objects which are no longer used by the resources.
Garbage collector only disposes the memory created by using the Reference Types means the objects which are in Heap Memory. The objects which are created using the Value Types will get cleared when they are out of Stack. Stack is the type where the value types gets push when they are created and get popped when they are used. So when the variable is used by the program and gets out of the scope, it will get popped up from the stack.
The Garbage collector will no take care of the stack objects.

Q 3. Abstraction is used to display only essential and necessary features of the Object to the outside world and hiding the unnecessary details. Abstract Classes and Interfaces can be used to achieve abstraction. 
Can I create the Constructor for an Abstract Class? 
Can I write Static methods inside Abstract class?? 
Can I inherit an Abstract class to Another Abstract class? If so, then if we can have an abstract method in the abstract base class the how the child abstract class will behave for the overriding of this method? Can I override the base class abstract method to the abstract child class? If so then do you think, Abstract class support override methods as we are now trying to implement the overriding in the child class which is abstract.
Ans. Abstraction is the way to expose the objects to the outside world as per our requirements. For example, using the public and private members of the class. If we don't want to expose the variable or method which is inside the class,m make them private. Abstraction is the compile time where the compiler gets behaviour of the members during the compilation of the program.
Abstract classes and interfaces are also the ways to achieve abstraction as when we define the Abstract members inside the abstract class or in Interface, we are exposing these members to outside world to use them by their implementation.
Yes, Constructor can be created for the abstract classes. The abstract class works based on the child class memory so when the object of the child class get created, it will call first the abstract class constructor and then then it will call the child class constructor.
Yes,  We can write the Static members(Methods and Properties) inside the abstract class where
 the static members can be called based on the class name. ClassName.MethodName(), ClassName.PropertyName etc.
Yes, Inheritance between the abstract classes is possible where we have both base class and inherited class both are abstract classes. So if we have an abstract method in the abstract base class and then we are inheriting this base class to the abstract child class, the abstract method can be overridden in the child abstract class but it is not mandatory to implement it there. We can also implement the abstract base class method to the last child class. So we can write the virtual, abstract as well as override methods inside the abstract class.

Q.4 Can we write properties inside interfaces? If so then what is the syntax to write a property in the Interface if the name of the property is ID and return type is integer?
Ans. Yes, We can define the public properties inside the Interface but as in interface all the members are public so we don't need to define the property as public.
Syntax: int ID {get; set;}

Q. 5 By default all the members of the Interface are public abstract. Can we write explicitly the 'Public' for the method? Do you think now my program will compile or will give a warning message? If it will give the warning message, then what the text for the warning message. If it will give the compilation error then what error you will get?
Ans. No, We can't write the explicitely 'Public' access specifier inside the interface. If we write the 'public' access specifier inside the interface, it will throw error during the compilation of the program that 'no access specifier are allowed inside the interface'.

Sr .Net Consultant | MCP Certified | Microsoft Technologies(.Net with Sql Server, MVC, AngularJS

My photo
Kuala Lumpur, Kuala Lumpur, Malaysia
Overall 17.0+ years of experience in software industry as a Programmer/Developer/Architect with Web & Windows application development and Maintenance, including analysis, design, coding, testing and documentation. • Proficient in Microsoft Technologies i.e. Visual Studio with .Net Framework. • Excellent analytical, problem solving, communication, interpersonal skills with the ability to handle multiple tasks or projects working independently or in a team. • Consistent attention to detail with an ability to analyze and interpret the implication of decisions to minimize bugs and create user-friendly applications. • Experience of Collaborating with Clients and Team Members. Ability to convey Technical Information at all levels. • Ability to work with team/management to ensure successful execution of project management tasks including scheduling, scope management, outside dependency coordination and priorities resolution. • Experience in working with global clients like UK, USA, Europe, Australia etc. and teams located remotely (e.g. Sydney, Australia, USA, and Sweden). • Worked with the Swedish client ManpowerGroup at onsite client location Stockholm, Sweden.