Skip to content

Instantly share code, notes, and snippets.

@rozer007
rozer007 / Faq.txt
Last active November 24, 2021 05:26
class and object in c#
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?
@rozer007
rozer007 / faq.txt
Created November 24, 2021 04:43
List and exception handling in c#
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;
@rozer007
rozer007 / Mcq.txt
Created November 23, 2021 12:10
STRING , STRINGBUILDER AND ITS FUNCTION IN C#
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)
@rozer007
rozer007 / Faq.txt
Last active November 24, 2021 04:43
Array in C#
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).
@rozer007
rozer007 / Faq.txt
Last active December 4, 2021 04:28
loops on c#
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?
@rozer007
rozer007 / Faq.txt
Last active November 26, 2021 08:16
operator ,math function and decision making in c#
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 ?
@rozer007
rozer007 / Mcq.txt
Created November 23, 2021 08:29
Introduction to C#
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
@rozer007
rozer007 / Faq.txt
Last active November 25, 2021 07:50
polymorphism and symbols in ruby
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 ?
@rozer007
rozer007 / Faq.txt
Created November 19, 2021 07:02
Enumerable in Ruby
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.
@rozer007
rozer007 / Faq.txt
Created November 19, 2021 06:33
File IO
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.