Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Revature Technical Interview C# Questions for freshers Actual Exam Updated Version Best fo, Exams of Computer Science

Revature Technical Interview C# Questions for freshers Actual Exam Updated Version Best for Last Minute Revision Updated 2023-2024 Latest

Typology: Exams

2023/2024

Available from 09/09/2023

john-wachira
john-wachira 🇺🇸

3.8

(62)

1.5K documents

1 / 16

Toggle sidebar

Related documents


Partial preview of the text

Download Revature Technical Interview C# Questions for freshers Actual Exam Updated Version Best fo and more Exams Computer Science in PDF only on Docsity!

Revature Technical Interview C# Questions for freshers

Actual Exam Updated Version Best for Last Minute

Revision Updated 2023-2024 Latest

Loops? --------- Correct Answer --------- while loop - repeats a statement of group of statements while a given condition is true for loop - executes a sequence of statements multiple times and abbreviates the code that manages the loop do while loop - executes first, then tests the condition nested loop - loop can be used inside another loop Loop control statements? --------- Correct Answer --------- break - terminates the loop or switch and transfers execution to the statement immediately following the loop or switch continue - causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating What is encapsulation? --------- Correct Answer --------- encapsulation refers to data hiding prevents access to implementation details What is an access specifier? --------- Correct Answer --------- defines the scope and visibility of a class member What are the access specifiers in C#? --------- Correct Answer --------- public - allows class to expose its member variables and member functions to all functions and objects outside the class private - only functions of the same class can access private members protected - access only granted within class and to derived classes internal - members of a class exposed to functions and objects within the assembly What is a method? --------- Correct Answer --------- a group of statements that together perform a task Define a method --------- Correct Answer --------- (parameter list) {

//method body } Elements of a method? --------- Correct Answer --------- access specifier - determines the visibility of a variable or a method from another class return type - data type of the value the method returns; void if no return value method name - unique identifier parameter list - used to pass and receive data from a method method body - set of instructions needed to complete the required activity What is recursion? --------- Correct Answer --------- a method calling itself Passing Parameters to a Method? --------- Correct Answer --------- value parameters - method copies the actual value of an argument into the formal parameter of the function reference parameters - method copies the reference to the memory location of an argument into the formal parameter output parameter - helps returning more than one value What is a nullable type? --------- Correct Answer --------- data type to which you can assign normal ranges of values as well as null values What is an array? --------- Correct Answer --------- a sequential collection of elements of the same type Declare an array --------- Correct Answer --------- datatype[] arrayName; Initialize an array --------- Correct Answer --------- datatype arrayName = new datatype[size]; How do you access array elements? --------- Correct Answer --------- by indexing the array name What is a foreach loop? --------- Correct Answer --------- a loop for iterating through a collection int[] n = new int[10]; foreach(int i in n) { //do something

}

What is a multi-dimensional array? --------- Correct Answer --------- elements in an array are arrays themselves What are the two properties of the String class? --------- Correct Answer --------- Chars - gets the Char object at a specified position in the String object Length - gets the number of characters in the current String object Some String methods? --------- Correct Answer --------- Compare Contains Substring Join What is a struct? --------- Correct Answer --------- value type data type that helps you make a single variable hold related data of various data types struct Books { public string title; public string author; public string subject; public int book_id; } Books book1; What is C#? --------- Correct Answer --------- general purpose, object-oriented programming language developed by Microsoft for the .NET framework What is CLI? --------- Correct Answer --------- common language infrastructure consists of all executable code and runtime ennvironment that allows use of various high-level languages on different computer platforms and architectures What is .NET? --------- Correct Answer --------- integrated framework that helps write windows applications, web applications, web services, etc. multi-platform, multi-language What is CLR? --------- Correct Answer --------- common language runtime

.NET compiles language into IL (intermediate language) which is converted to native code and run by machine What is using? --------- Correct Answer --------- using keyword is used to include the System namespace in the program What is a namespace? --------- Correct Answer --------- a collection of classes Type variables in C#? --------- Correct Answer --------- value types reference types pointer types Value types? --------- Correct Answer --------- contain actual data stored in the variable bool, byte, char, decimal, double, float, int, long, short, Reference types? --------- Correct Answer --------- refer to a memory location object, dynamic, string What is object? --------- Correct Answer --------- base class for all data types in C# common type system (CTS) What is boxing? --------- Correct Answer --------- implicit type conversion of a value type to its corresponding object type What is unboxing? --------- Correct Answer --------- explicit type conversion of an object type to its value type Dynamic type? --------- Correct Answer --------- any type of value may be stored type checking for this type is performed at run-time String type? --------- Correct Answer --------- allows you to pass any string values to a variable User-defined reference types? --------- Correct Answer --------- class interface delegate Pointer type? --------- Correct Answer --------- store the memory address of another type

What is implicit type conversion? --------- Correct Answer --------- type-safe automatic conversion from a smaller to larger integral type of conversion from derived class to base class What is explicit type conversion? --------- Correct Answer --------- require a cast operator converts larger integral type to smaller integral type or from base class to derived class C# Type conversion methods? --------- Correct Answer --------- ToBoolean ToByte ToChar ToDateTime ToDecimal ToDouble ToInt ToInt ToInt ToSingle ToString ToType Define variables --------- Correct Answer --------- <data_type> <variable_name>; Initializing variable --------- Correct Answer --------- <data_type> <variable_name> = ; Literals? --------- Correct Answer --------- constants that refer to fixed values that the program may not alter during execution can be integer, floating, character, string How are constants defined? --------- Correct Answer --------- const Arithmetic operators? --------- Correct Answer --------- + adds operands

  • subtracts second operand from first
  • multiplies two operands / divides numerator by denominator % remainder after an integer division ++increases integer value by 1 --decreases integer value by 1 Relational operators? --------- Correct Answer --------- == checks equality != not equal

greater than < less than = greater than or equal to <= less than or equal to Logical operators? --------- Correct Answer --------- && and || or ! not Assignment operators? --------- Correct Answer --------- = assigns value of left side to right side += adds right operand to left operand and assigns value to left operand

    • subtracts right operand from left operand and assigns value to left operand += multiplies operands and assigns value to left operand /= divides left operand with right operand and assigns value to left operand %= takes modulus and assigns to left operand Miscellaneous operators? --------- Correct Answer --------- sizeof() returns size of data type

typeof() returns the type of a class ?: ternary operator if statement --------- Correct Answer --------- if(boolean expression) { //statement; } if else statement --------- Correct Answer --------- if(boolean expression) { //statement } else { //statement } if else-if else statement --------- Correct Answer --------- if(boolean expression) { //statement } else if(boolean expression) { //statement } else { //statement } Nested if statement --------- Correct Answer --------- an if statement can be used inside another if statement Switch statement --------- Correct Answer --------- switch(expression) { case constant: statement; break; case constant: statement; break; default: //optional statement; }

? : --------- Correct Answer --------- exp1? exp2 : exp exp1 evaluated if true, exp 2 if false, exp Features of structs? --------- Correct Answer --------- can have methods, fields, indexers, properties, operator methods, and events cannot inherit other structs or classes can implement interfaces cannot be specified as abstract, virtual, or protected can be instantiated without new keyword Class versus struct? --------- Correct Answer --------- classes are reference types and structs are value types structs do not support inheritance structs cannot have default constructor What is an enum? --------- Correct Answer --------- a set of integer named constants value data type enum <enum_name> { enumeration list } What is a class? --------- Correct Answer --------- a blueprint for a data type defines what an object of the class consists of and what operations can be performed on that object objects are instances of a class methods and variables that constitute a class are called members of the class What is a constructor? --------- Correct Answer --------- special member function of a class that is executed whenever we create new objects of the class

has the same name as that of the class and does not have any return types What is a default constructor? --------- Correct Answer --------- does not have parameters and will be called if no other constructors are declared What is a parametrized constructor? --------- Correct Answer --------- constructor that takes a parameter list What is a destructor? --------- Correct Answer --------- special member function of a class that is executed whenever an object of its class goes out of scope has same name as the class with a (~) prefix What is static? --------- Correct Answer --------- only one copy in memory static variables are used for defining constants because their values can be retrieved by invoking the class without creating an instance of it static variables can be initialized outside the member function or class definition static function can only access static variables What is inheritance? --------- Correct Answer --------- allows us to define a class in terms of another class with pre-existing members new class is the derived class existing class is the base class Is-a relationship : Does C# allow multiple inheritance? --------- Correct Answer --------- no, but a class can implement multiple interfaces What is polymorphism? --------- Correct Answer --------- having many forms one interface, multiple functions How is polymorphism achieved? --------- Correct Answer --------- method overloading method overriding What is static polymorphism? --------- Correct Answer --------- mechanism of linking a function with an object during compile time

method overloading operator overloading What is method overloading? --------- Correct Answer --------- multiple definitions for the same function name in the same scope definition of the function must differ from each other by the types and/or the number of arguments What is dynamic polymorphism? --------- Correct Answer --------- implemented by abstract classes and virtual functions C# allows the creation of abstract classes that are used to provide partial class implementation of an interface abstract classes contain abstract methods, which are implemented by the derived class Rules of abstract classes? --------- Correct Answer --------- cannot be instantiated cannot declare an abstract method outside an abstract class when a class is declared sealed, it cannot be inherited; abstract classes cannot be declared sealed What is a virtual function? --------- Correct Answer --------- function defined in a class you want to be implemented differently in a derived class the implementation will be determined at runtime called method overriding What is an interface? --------- Correct Answer --------- syntactical contract that all classes inheriting the interface must follow define properties, methods, and events declare but do not implement members Declare an interface --------- Correct Answer --------- declared using the interface keyword public by default interface named begins with "I"

What is a namespace? --------- Correct Answer --------- designed for providing a way to keep one set of names separate from another collection of classes What is the using keyword? --------- Correct Answer --------- states that the program is using the names in the given namespace What is a regular expression? --------- Correct Answer --------- pattern that could be matched against an input text consists of one or more character literals, operators, or constructs What is an exception? --------- Correct Answer --------- an exception is a problem that arises during the execution of a program C# exception is a response to an exceptional circumstance that arises while a program is running built upon four keywords: try catch finally throw What does the try block do? --------- Correct Answer --------- identifies a block of code for which a particular exception is activated What does the catch block do? --------- Correct Answer --------- indicates that an exception was caught and the code to execute a response to the exception What does the finally block do? --------- Correct Answer --------- Executes a set of statements whether an exception is caught or not What does throw mean? --------- Correct Answer --------- throws an exception when a problem shows up What are some pre-defined C# exception classes? --------- Correct Answer --------- IOException IndexOutOfRangeException NullReferenceException DivideByZeroException InvalidCastException OutOfMemoryException StackOverflowException

What is exception handling? --------- Correct Answer --------- structured solution to dealing with exception with try and catch blocks What is a file? --------- Correct Answer --------- collection of data stored in a disk with a specific name and directory path What is a stream? --------- Correct Answer --------- a file that is opened for reading or writing sequence of bytes passing through the communication path What is an input stream? --------- Correct Answer --------- used for reading data from a file What is an output stream? --------- Correct Answer --------- used for writing into the file Some C# I/O classes? --------- Correct Answer --------- File FileStream MemoryStream Path StreamReader StreamWriter StringReader StringWriter What is an attribute? --------- Correct Answer --------- a declarative tag that is used to convey information to runtime about the behaviors of various elements like classes, methods, structures, enumerators, assemblies, etc. in your program [attribute(positional_parameters, name_parameter = value, ..)] element What is reflection? --------- Correct Answer --------- reflection objects are used for obtaining type information at runtime What are the applications of reflection? --------- Correct Answer --------- allows view attribute information at runtime allows examining various types in an assembly and instantiate these types allows late binding to methods and properties allows creating new types at runtime and then performs some tasks using those types

What is a property? --------- Correct Answer --------- named members of classes, structs, and interfaces member variables or methods in a class or struct are called fields properties are an extension of fields and are accessed using the same syntax use accessors through which the values of the private fields can be read, written, or manipulated What is an indexer? --------- Correct Answer --------- allows an object to be indexed such as an array when you define an indexer for a class, this class behaves similar to a virtual array you can access the instance of this class using the array access operator([]) What is a delegate? --------- Correct Answer --------- a rerference type variable that holds the reference to a method used for implementing events and the call-back methods How do you declare a delegate? --------- Correct Answer --------- delegate <return_type> <delegate_name> (<parameter_list>) How do you instantiate a delegate? --------- Correct Answer --------- must be created with the new keyword and be associated with a particular method if the method takes the same arguments What is an event? --------- Correct Answer --------- user actions such as key clicks, mouse movements, or some occurrence applications need to respond to events when they occur events are declared and raised in a class and associated with the event handlers using delegates within the same class or some other class What is a publisher class? --------- Correct Answer --------- the class containing the event What is the subscriber class? --------- Correct Answer --------- the class that accepts the event What is the publisher object? --------- Correct Answer --------- contains the definition of the event and the delegate invokes the event and it is notified to other objects

What is the subscriber object? --------- Correct Answer --------- accepts the event and provides an event handler Declare an event --------- Correct Answer --------- pulbic delegate string MyDel(string str); class EventProgram{ event MyDel MyEvent; public EventProgram(){ this.MyEvent += new MyDel(this.WelcomeUser);} public string WelcomeUser(string username) { return "Welcome " + username;} What is a collection? --------- Correct Answer --------- specialized classes for data storage and retrieval provide support for stacks, queues, lists, and hash tables Common collections? --------- Correct Answer --------- List - ordered collection of an object that can be indexed individually Dictionary - each item has a key/value pair; the key is used to access items in the collection What are Generics? --------- Correct Answer --------- allow you to delay the specification of the data type of programming elements in a class or method until it is actually used in the program allow you to write a class or method that can work with any data type What are the features of Generics? --------- Correct Answer --------- maximize code reuse, type safety, and performance can create generic collection classes can create your own generic interfaces, classes, methods, events, and delegates you may get information on the types used in a generic data type at run-time by means of reflection What is an anonymous method? --------- Correct Answer --------- provide a technique to pass a code block as a delegate parameter method without a name, just the body

you do not specify the return type in an anonymous method; it is inferred from the return statement inside the method body What is a thread? --------- Correct Answer --------- the execution path of a program each thread defines a unique flow of control What is the Thread Life Cycle? --------- Correct Answer --------- The Unstarted State - instance of the thread is created but the Start method is not called The Ready State - thread is ready to run and waiting CPU cycle The Not Runnable State - thread is not executable sleep method called wait method called blocked by I/O The Dead State - thread completes execution or is aborted How do you create a thread? --------- Correct Answer --------- extend the Thread class and call the Start() method How do you pause a thread? --------- Correct Answer --------- call the sleep() method How do you destroy a thread? --------- Correct Answer --------- call the abort() method What is LINQ? --------- Correct Answer --------- language-integrated query set of technologies based on the integration of query capabilities directly into the C# language What is query syntax? --------- Correct Answer --------- invoke standard query operators with names such as where, select, groupby, join, max, average What is method syntax? --------- Correct Answer --------- semantically identical to query syntax but query syntax is compile to method syntax when code is compiled What is a lambda expression? --------- Correct Answer --------- an anonymous function used to create delegates or expression tree types you can write local functions that can be passed as arguments or returned as the value of function calls particularly helpful with writing LINQ queries

x => x * x (input-parameters) => expression What does asynchronous programming avoid? --------- Correct Answer --------- performance bottlenecks and overall responsiveness of your application Which application areas benefit from async programming? --------- Correct Answer ------- -- web access - HttpClient working with files - StreamReader, StreamWriter working with images WCF programming Which two keywords make an asynchronous method? --------- Correct Answer --------- async and await async declares the method asynchronous other code in the method runs independently until the await operator is reached