I initially posted this in Chit Chat, so some of you may have seen it, some of you may not....anyway these are some questions I was asked at an interview I had the other day. What I would like is to compare my answers with your guys to determine if I answered them correctly or at least closely...my answers are below the questions.
My AnswersCode:C# Questions 1. What does the keyword static mean when applied to a class member? 2. Declare a method called calculate that takes one integer, adds one and returns the result. Allow this method to be overridden by an inheriting class. 3. What is the difference between a class and a struct? 4. What is the difference between a class and an interface? 5. What are the .Net web authentication options and which one would generally be used for a secured/public site? 6. What are some .Net options for maintaining session state? 7. What is a Singleton? Database Questions Using the EMPLOYEE and JOBS tables, fill in the following stored procedure template so that it removes a job by job_id and all associated employees ensuring that both updates succeed or fail together. CREATE PROCEDURE deleteJob @jobid smallint AS
Code:1. It means the method can be called through the class without instantiating the class. 2. Public virtual int calculate(int value) { newValue = value + 1; return newValue; } 3. The class object is stored in the heap and struct object is stored in the stack. Therefore accessing and removing data from the struct is faster than for a class. 4. You can instantiate a class but you cannot instantiate an interace you can only offer the functionality of that interface. 5. None Windows Authentication –Secured side IIS Authentication Forms Authentication – Public Side 6. In process and out of process. (wasn't sure about this one?) 7. This ensures that a class can only be instantiated once. Database Answer: CREATE PROCEDURE deleteJob @jobid smallint AS BEGIN BEGIN TRAN IF EXISTS (SELECT * FROM JOBS WHERE job_id = @jobid) DELETE FROM JOBS WHERE job_id = @jobid IF @@ERROR <> 0 BEGIN RAISERROR(‘Could not delete row from Jobs – Abort’, 16,1) GOTO Errorhandler END IF EXISTS(SELECT * FROM EMPLOYEES WHERE job_id = @jobid) DELETE FROM EMPLOYEES WHERE job_id = @jobid IF @@ ERROR <> 0 BEGIN RAISERROR(‘Could not delete row from Employees – Abort’, 16,1) GOTO Errorhandler END COMMIT RETURN Errorhandler: ROLLBACK TRAN RETURN END




Reply With Quote