Skip to content

Instantly share code, notes, and snippets.

@rozer007
rozer007 / Faq.txt
Created December 4, 2021 05:37
Tables in lua
Q1. How to create a empty tables in lua?
ans: table_name = { } , this will create a empty table.
Q2.What will be the values of an unassigned index in tables?
ans: nil
Q3. Are tables mutables?
ans Yes,tables are mutables.
Q4.Are there arrays and vectors in lua?
@rozer007
rozer007 / Faq.txt
Created December 4, 2021 05:07
Strings in lua
Q1) Can't we use the + operator to concatenate two strings?
Ans: No ,In lua to concatenate two strings we should .. operator. eg. st1..st2.
Q2) How can we find the length of a string without using the string length function ?
ans: We can use # symbol in front of the string to find the length of the string.
Q3) Can we access the character of a string using thier indexes?
ans: No we can't and if we try to access it will nil value.
Q4) what is gmatch function in string?
@rozer007
rozer007 / Faq.txt
Created December 4, 2021 04:35
Loops in lua
Q1. Does lua have continue keyword ?
ans : NO,we can use goto to work like a continue keyword.
Q2. What does break statement do?
ans: This will terminate the loop.
Q3. What type of loop in lua is similar to do while loop in other language?
ans: repeat until loop is pretty muat similar to do while since it check the condition after the execution.
Q4. what is the syntax of foreach loop in lua for iterating a table?
@rozer007
rozer007 / Faq.txt
Created December 2, 2021 11:27
Math function and conditional in lua
Q1. How can we generate a same random number all the time?
ans: We will have to set the randomseed(constant) value to some constant then it will generate same random all the time.
Q2. how can we create a local variable in lua?
ans: we have use local keyword to create a local variable in lua. eg local x=10.
Q3.What is the syntax of ternary operator in lua?
ans: var_name = condition and <if true> or <if false> eg. bool=1>10 "right" or "wrong"
Q4.What is the math function to find the maximum between two numbers?
@rozer007
rozer007 / Faq.txt
Created December 2, 2021 10:59
Basics in lua
Q1.How can we accept a integer value from a user ?
ans : we use tonumber() function to convert the string input from the user to numbers.
Q2.what is the synax for multiline comment in lua?
ans: --[[ comments --]]
Q3.What will be the default value when we create any variable?
ans: nil
Q4.How can we check the type of a variable in lua?
@rozer007
rozer007 / Faq.txt
Created November 26, 2021 12:21
interface and null safety in kotlin
Q1) What is an elvis operator?
ans: It is an operator that give a default value when the original value is null.
Q2) Why do we use interface ?
ans: We use interface to achieve total abstraction.
Q3) Why can't we assign null to a normal variable?
ans: Because to eliminate the danger of null references.
Q4)What will happen if we assigned null to a normal variable?
@rozer007
rozer007 / Faq.txt
Created November 24, 2021 06:43
Delegate and lambda expression and files in c#
Q1 can a static method associated with a class having same parameter and retunn typecall delegate?
ans : yes , it can be call just the return typr and parameter must be satisfied.
Q2 What is a lambda operator?
ans: this "=>" is known as the lambda operator in c#.
Q3. How can we know that we have reach the end of a file while reading file?
ans: we just need to check if the file.ReadLine == null, if null then it had reached the end.
Q4 What is anonymous function?
@rozer007
rozer007 / Mcq.txt
Created November 24, 2021 06:03
GENERIC , ENUMERATION AND STRUCTURE IN C#
Q1 What is the correct way of defining a generic class with only one variable?
a. class class_name<T>
b. class class_name<Tkey>
c. None of the above
d. Both a and b
ans d
Q2 what keyword is use to define enumeration in c#
@rozer007
rozer007 / Faq.txt
Created November 24, 2021 05:51
ABSTRACT CLASS ,INTERFACE AND OPERATOR OVERLOADING IN C#
Q1 What type of method is define in interface?
ans: Only abstact method can be define in an interface.
Q2 Can we write the body of the function in simple method in abstract class.
ans : yes we can write the body of the simlpe method but we cannot write for the abstract method.
Q3.What type of polymorphism is operator overloading?
ans:It is a compile time polymorphism.
Q4 what keyword is use to access the abstract method from the abstract class?
@rozer007
rozer007 / Faq.txt
Created November 24, 2021 05:35
Inheritanec in c#
1. What is the need of inheritance?
Ans- We use inheritance because it provides us code reusability and reduces our code. It also reduces data redundancy and duplicacy.
2. Does C# supoorts multiple inheritance?
Ans- No C# only doesn't support multiple inheritance but we can use modules to implement multiple inheritance.
3. How can we create a method to override the method in base class
ans: we will use the new keyword use the function name while declaring a function for overriding.