This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. What are getter setter methods? | |
Ans - Getter and Setter methods are used to retrieve and set the data of instance variables in class. | |
2. How can we write a construtor function in c# | |
ans: A constructor function in C# must have the same name as the class , and we either give argument or no parameter. | |
3. What is the keyword that is use in setter method when we write a setter manually? | |
ans: value keyword is use to write a setter method. | |
4. How can we access a static variable? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) How to create a 2d array in list? | |
ans: List<List< data_type>> 2dlist = new List<List< data_type>>(); | |
2dlist.Add(new List<data_type>()) | |
Q2) How can we raise an exception in c#? | |
ans: We can raise an exception manually in c# using the throw keyword. | |
Q3) How to get the number of element in a nth dimension of a List? | |
ans: We can get the number of element by this statement list[n-1].Count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) What will be the output of this code? | |
string str="hello pepcoder"; | |
Console.WriteLine(str.Substring(0,8)); | |
a) hello pe | |
b) hello pep | |
c) ello pe | |
d) ello pep | |
ans: b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) Difference between List and array? | |
ans Array are static with a fixed size whereas List are dynamic and size can be change according to our need. | |
Q2) What does split function do? | |
ans: It convert a string into a array by spliting the string by a character and each word is stores as an element in an array. | |
Q3) How can we add at the front of a list? | |
ans: We can use the Insert function to add at index 0. | |
eg. list.Insert(0,element you want to add). | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) What does break statement do? | |
ans: This will terminate the loop. | |
Q2) What does continue do? | |
ans: This will skip the rest of the code of the loop and start the next iteration. | |
Q3) Why does do while loop execute atleast one even the condition is false? | |
ans: It is because the condition is check at the end of the loop. | |
Q4) Difference between other loop and foreach loop? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1. What will happen if we don't write break after a case in switch case? | |
ans: The code under that case will be executed and execution it will move to the next case untill it meet a break statement. | |
Q2. Can goto work as loop? | |
ans: Yes ,but it is not a good way of using goto statement. | |
Q3.How does Math.abs() work? | |
ans: It will give the absolute value of a number ie. for -2 it will give 2.Here the signed are ignored. | |
Q4. Differnce between ceiling and round ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1. How to take a input in c# : | |
a) Console.writline() | |
b) Console.Readline() | |
c) Console.Readall() | |
d) Console.ReadLine() | |
ans: d) Console.ReadLine() | |
Q2) Which of the following are not datatypes of c# : | |
a) int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) How to declare a symbol in ruby? | |
ans: Before the symbol name we need use ":" character to define a symbol. | |
Q2) How many type of polymorphism can be done in ruby? | |
ans: Two types : i) using inheritance | |
ii) using duck typing | |
Q3) What is duck typing in polymorphism ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) What are enumerable in ruby? | |
ans:It is module which give the class the capabilities to use collection method. | |
Q2) What function is necessary to include in class to include enumerable? | |
ans: def each function is required to present in the class. | |
Q3) What is the function to check whether a value is present in the enumerable or not? | |
ans: We use find() function. | |
Q4) What are the which have pre defined Enumerable module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) What is difference between a and a+ mode? | |
ans: a - Append to a file.The file is created if it does not exist. | |
a+ - Open a file for reading and appending. The file is created if it does not exist. | |
Q2) Is it mandatory to close the file after opening. | |
ans: Yes ,if we didn't close then it will leak file descriptors. | |
Q3) When we use File.open() ,what type of object is created? | |
ans: File object ,it can be check using .class function. |