C Language is A High-level And General-purpose programming Language that Is Ideal For Developing Firmware Or Portable Applications.
1.What is C language?
The C programming language is a standardized programming language developed in the early 1970s byKen Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to manyother operating systems, and is one of the most widely used programming languages. C is prized for itsefficiency, and is the most popular programming language for writing system software, though it is alsoused for writing applications.
2.What does static variable mean?
There are 3 main uses for the static.
1. If you declare within a function: It retains the value between function calls
2. If it is declared for a function name: By default function is extern..so it will be visible from other files ifthe function declaration is as static..it is invisible for the outer files
3. Static for global variables: By default we can use the global variables from outside files If it is staticglobal..that variable is limited to with in the file.
#includeint t = 10;main(){int x = 0;void funct1();funct1();printf("After first call \n");funct1();printf("After second call \n");
funct1();printf("After third call \n");}void funct1(){static int y = 0;int z = 10;printf("value of y %d z %d",y,z);y=y+10;}
JOBSMATE.COM
value of y 0 z 10 After first callvalue of y 10 z 10 After second callvalue of y 20 z 10 After third call
3.What are the different storage classes in C?
C has three types of storage: automatic, static and allocated. Variable having block scope and withoutstatic specifier have automatic storage duration. Variables with block scope, and with static specifier havestatic scope. Global variables (i.e., file scope) with or without the static specifier also have static scope.Memory obtained from calls to malloc(), alloc() or realloc() belongs to allocated storage class.
4.What is hashing?
To hash means to grind up, and that's essentially what hashing is all about. The heart of a hashingalgorithm is a hash function that takes your nice, neat data and grinds it into some random-looking integer.The idea behind hashing is that some data either has no inherent ordering (such as images) or is expensiveto compare (such as images). If the data has no inherent ordering, you cant perform comparison searches.
5.Can static variables be declared in a header file?
You cant declare a static variable without defining it as well (this is because the storage class modifiersstatic and extern are mutually exclusive). A static variable can be defined in a header file, but this wouldcause each source file that included the header file to have its own private copy of the variable, which isprobably not what was intended.
6.Can a variable be both constant and volatile?
Yes. The const modifier means that this code cannot change the value of the variable, but that does notmean that the value cannot be changed by means outside this code. The function itself did not change thevalue of the timer, so it was declared const. However, the value was changed by hardware on the computer,so it was declared volatile. If a variable is both const and volatile, the two modifiers can appear in eitherorder.
7.Can include files be nested?
Yes. Include files can be nested any number of times. As long as you use precautionary measures, you canavoid including the same file twice. In the past, nesting header files was seen as bad programming practice,because it complicates the dependency tracking function of the MAKE program and thus slows downcompilation.Many of today's popular compilers make up for this difficulty by implementing a concept called precompiledheaders, in which all headers and associated dependencies are stored in a precompiled state.
8.What is a null pointer?
There are times when its necessary to have a pointer that doesn't point to anything. The macro NULL,defined in , has a value that's guaranteed to be different from any valid pointer. NULL is a literal zero,possibly cast to void* or char*.
Some people, notably C++ programmers, prefer to use 0 rather than NULL.The null pointer is used in three ways:1) To stop indirection in a recursive data structure.2) As an error value.3) As a sentinel value.
9.What is the output of printf("%d") ?
When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothingafter %d so compiler will show in output window garbage value.
10.What is the difference between calloc() and malloc() ?
calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block isinitialized to 0. The total number of memory allocated will be (number_of_elements * size).
malloc(...) takes in only a single argument which is the memory required in bytes. malloc(...) allocated bytesof memory and not blocks of memory like calloc(...).
malloc(...) allocates memory blocks and returns a void pointer to the allocated space, or NULL if there isinsufficient memory available.
calloc(...) allocates an array in memory with elements initialized to 0 and returns a pointer to the allocatedspace. calloc(...) calls malloc(...) in order to use the C++ _set_new_mode function to set the new handlermode.
11.What is the difference between printf() and sprintf() ?
sprintf() writes data to the character array whereas printf(...) writes data to the standard output device.
12.How to reduce a final size of executable?
Size of the final executable can be reduced using dynamic linking for libraries.
13.Can you tell me how to check whether a linked list is circular?
Create two pointers, and set both to the start of the list. Update each as follows:
while (pointer1) {pointer1 = pointer1->next;pointer2 = pointer2->next;if (pointer2) pointer2=pointer2->next;if (pointer1 == pointer2) {print ("circular");}}
If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1,or the item before that. Either way, its either 1 or 2 jumps until they meet.
14.Advantages of a macro over a function?
Macro gets to see the Compilation environment, so it can expand __ __TIME__ __FILE__ #defines. It isexpanded by the preprocessor.
For example, you can do this without macros#define PRINT(EXPR) printf( #EXPR %d\n EXPR)PRINT( 5+6*7 ) // expands into printf(5+6*7=%d5+6*7 );you can define your mini language with macros:#define strequal(A,B) (!strcmp(A,B))
15.What is the difference between strings and character arrays?
A major difference is: string will have static storage duration, whereas as a character array will not, unlessit is explicitly specified by using the static keyword.
Actually, a string is a character array with following properties:* the multibyte character sequence, to which we generally call string, is used to initialize an array of staticstorage duration. The size of this array is just sufficient to contain these characters plus the terminatingNUL character.
* it not specified what happens if this array, i.e., string, is modified.
* Two strings of same value[1] may share same memory area.
16.Write down the equivalent pointer expression for referring the same element a[i][j][k][l] ?
a[i] == *(a+i)a[i][j] == *(*(a+i)+j)a[i][j][k] == *(*(*(a+i)+j)+k)a[i][j][k][l] == *(*(*(*(a+i)+j)+k)+l)
17.Which bit wise operator is suitable for checking whether a particular bit is on or off?
The bitwise AND operator. Here is an example:
enum {KBit0 = 1,KBit1,KBit31,};
if ( some_int & KBit24 )printf ( Bit number 24 is ON\n);elseprintf ( Bit number 24 is OFF\n);
18.Which bit wise operator is suitable for turning off a particular bit in a number?
The bitwise AND operator, again. In the following code snippet, the bit number 24 is reset to zero.
some_int = some_int & ~KBit24;
19.Which bit wise operator is suitable for putting on a particular bit in a number?
The bitwise OR operator. In the following code snippet, the bit number 24 is turned ON:some_int = some_int | KBit24;
20.Does there exist any other function which can be used to convert an integer or a float to a string?
Some implementations provide a nonstandard function called itoa(), which converts an integer to string.
#includechar *itoa(int value, char *string, int radix);DESCRIPTIONThe itoa() function constructs a string representation of an integer.PARAMETERSvalue: Is the integer to be converted to string representation.string: Points to the buffer that is to hold resulting string.The resulting string may be as long as seventeen bytes.radix: Is the base of the number; must be in the range 2 - 36.A portable solution exists. One can use sprintf():char s[SOME_CONST];int i = 10;float f = 10.20;sprintf ( s, %d %f\n,i, f );
21.Why does malloc(0) return valid memory address ? What's the use?
malloc(0) does not return a non-NULL under every implementation. An implementation is free to behavein a manner it finds suitable, if the allocation size requested is zero. The implmentation may choose any ofthe following actions:
* A null pointer is returned.* The behavior is same as if a space of non-zero size was requested. In this case, the usage of return valueyields to undefined-behavior.
Notice, however, that if the implementation returns a non-NULL value for a request of a zero-lengthspace, a pointer to object of ZERO length is returned! Think, how an object of zero size should berepresented
For implementations that return non-NULL values, a typical usage is as follows:voidfunc ( void ){int *p; /* p is a one-dimensional array, whose size will vary during the the lifetime of the program */size_t c;p = malloc(0); /* initial allocation */
if (!p){perror (?FAILURE? );return;}/* */
while (1){c = (size_t) ; /* Calculate allocation size */p = realloc ( p, c * sizeof *p );/* use p, or break from the loop *//* */}return;}Notice that this program is not portable, since an implementation is free to return NULL for a malloc(0)request, as the C Standard does not support zero-sized objects.
22.Difference between const char* p and char const* p
In const char* p, the character pointed by p is constant, so u cant change the value of character pointed byp but u can make p refer to some other location.
In char const* p, the ptr ?p? is constant not the character referenced by it, so u cant make p to reference toany other location but u can change the value of the char pointed by p
23.What is the result of using Option Explicit?
want to include with the angled brackets < and >. This method of inclusion tells the preprocessor to look for the file in the predefined default location. This predefined default location is often an INCLUDE environment variable that denotes the path to your include files.
INCLUDE=C:\COMPILER\INCLUDE;S:\SOURCE\HEADERS; using the #include version of fileinclusion, the compiler first checks the C:\COMPILER\INCLUDE directory for the specified file. If thefile is not found there, the compiler then checks the S:\SOURCE\HEADERS directory. If the file is stillnot found, the preprocessor checks the current directory.
This method of inclusion tells the preprocessor to look for the file in the current directory first, then lookfor it in the predefined locations you have set up. Using the #include file version of file inclusion andapplying it to the preceding example, the preprocessor first checks the current directory for the specifiedfile. If the file is not found in the current directory, the C:COMPILERINCLUDE directory is searched. Ifthe file is still not found, the preprocessor checks the S:SOURCEHEADERS directory.
because these headers are often modified in the current directory, and you will want the preprocessor to useyour newly modified version of the header rather than the older, unmodified version.
24.What is the benefit of using an enum rather than a #define constant?
The use of an enumeration constant (enum) has many advantages over using the traditional symbolicconstant style of #define. These advantages include a lower maintenance requirement, improved programreadability, and better debugging capability.1) The first advantage is that enumerated constants are generated automatically by the compiler.Conversely, symbolic constants must be manually assigned values by the programmer.
2) Another advantage of using the enumeration constant method is that your programs are more readable andthus can be understood better by others who might have to update your program later.
3) A third advantage to using enumeration constant
25.Can we have a pointer to a function?
a. Not possible
b. Possible
c. Depends on the return value
d. Depends on the # of arguments
Answer:b.Possible
26.Write a function to swaps the values of two integers.
a. No solution exist.
b. Solution need 2 extra variables
c Solution exist without any extra variables
d. Solution need 1 extra variable
Solution c Solution exist without any extra variables
1. void swap(int a, int b){int c;c=a;a=b;b=c;}
2. void swap (int a, int b){
a=a+b;
b=a-b;
a=a-b;
}Solution2 is the best solution since no extra variable is required.
27.Which of the following Bitwise operators can be used efficiently to swap two numbers? a. & b. ^ c. | d. ||
Solution:b ^
a=a^bb=a^ba=a^b Now ‘a’ will have ‘b’s initial value and wise-versa.
28.Do you find any issue with the above snippet of code?
a. No issues
b. P is a bad pointer
c P is a void pointer
d. Both 2& 3
Answer: b. P is a bad pointer
When a pointer is first allocated, it does not have a pointee. The pointer is "uninitialized" or simply "bad". Ade-reference operation on a bad pointer is a serious run-time error. If you are lucky, the de-referenceoperation will crash or halt immediately (Java behaves this way). If you are unlucky, the bad pointerde-reference will corrupt a random area of memory, slightly altering the operation of the program so that itgoes wrong some indefinite time later. Each pointer must be assigned a pointee before it can supportde-reference operations. Before that, the pointer is bad and must not be used. Bad pointers are verycommon. In fact, every pointer starts out with a bad value. Correct code overwrites the bad value with acorrect reference to a pointee, and thereafter the pointer works fine. There is nothing automatic that gives apointer a valid pointee.
void BadPointer(){
int* p; // allocate the pointer, but not the pointee
*p = 42; // this de-reference is a serious runtime error
}
29.Can we have a pointer to a function?
void func(int a){}void main(){void (*fp)(int);fp=func;fp(1);}
30.Write a function to swaps the values of two integers.
31.Do you find any issue with the above snippet of code?
When a pointer is first allocated, it does not have a pointee. The pointer is "uninitialized" or simply "bad". Ade-reference operation on a bad pointer is a serious run-time error. If you are lucky, the de-reference operation willcrash or halt immediately (Java behaves this way). If you are unlucky, the bad pointer de-reference will corrupt arandom area of memory, slightly altering the operation of the program so that it goes wrong some indefinite time later.Each pointer must be assigned a pointee before it can support de-reference operations. Before that, the pointer is badand must not be used. Bad pointers are very common. In fact, every pointer starts out with a bad value. Correct codeoverwrites the bad value with a correct reference to a pointee, and thereafter the pointer works fine. There is nothingautomatic that gives a pointer a valid pointee.
32.void add(int a, int b) { int c; c = a + b; add (1,1); } What is the result of above funtion?
a. Sum of a,b,1
b. Results in Buffer Overflow
c Results in Compiler Error
d Results in Stack Overflow
Answer: d. Results in Stack Overflow
When a function is called recursively, sometimes infinite recursions occur which results in STACK OVERFLOW. Whatdoes it mean? Well when a function is called,
1. First it will evaluate actual parameter expressions.
2. Then, memory is allocated to local variables.
3. Store caller’s current address of execution (return address of the current function) and then continue execute therecursive call.
4. Then it executes rest of the function body and reaches end and returns to the caller’s address.
Now when a function is infinitely called (recursively) without a proper condition to check its recursive, then only first 3steps keep executing and function will never reach step 4 to finish execution and return to previous function. In thisway, function will keep allocating memory and at some point of time it will go out of memory or reaches stack limit andwill never be able to accommodate another function and hence crashes. This is called stack overflow.
33.Which of the following will initialize the new memory to 0 ?
a. malloc
b. free
c. new
d delete
Answer: c. new
“new” will initlize the new memory to 0 but “malloc()” gives random value in the new alloted memory location
34.Which of the following standard C library converts a string to a long integer and reports any .leftover. numbers that could not be converteda. atol b. atoi c. stol d. strtol.
Answer: d. strtol
strtol() Converts a string to a long integer and reports any .leftover. numbers that could not be converted.atoi() Converts a string to an integer.atol() Converts a string to a long integer.
35.How do you construct an increment statement or decrement statement in C?
There are actually two ways you can do this. One is to use the increment operator ++ anddecrement operator. For example, the statement means to increment the value of x by 1. Likewise, thestatement x means to decrement the value of x by 1. Another way of writing increment statements is to usethe conventional + plus sign or minus sign. In the case of x++, another way to write it is x= x +1?.
36.Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
Placing comment symbols /* */ around a code, also referred to as commenting out, is a way ofisolating some codes that you think maybe causing errors in the program, without deleting the code. Theidea is that if the code is in fact correct, you simply remove the comment symbols and continue on. It alsosaves you time and effort on having to retype the codes if you have deleted it in the first place.
37.What is the equivalent code of the following statement in WHILE LOOP format?
[c]for (a=1; a<=100; a++)printf ("%d\n", a * a);[/c]
Answer:[c]a=1;while (a<=100) { printf ("%d\n", a * a); a++;}[/c]
38.What is spaghetti programming?
Spaghetti programming refers to codes that tend to get tangled and overlapped throughout theprogram. This unstructured approach to coding is usually attributed to lack of experience on the part of theprogrammer. Spaghetti programming makes a program complex and analyzing the codes difficult, and somust be avoided as much as possible.
39.In C programming, how do you insert quote characters (and ) into the output screen?
This is a common problem for beginners because quotes are normally part of a printf statement.To insert the quote character as part of the output, use the format specifiers \? (for single quote), and \? (fordouble quote).
40.What is the use of a '0' character?
It is referred to as a terminating null character, and is used primarily to show the end of a stringvalue.
41.What is the difference between the = symbol and == symbol?
The = symbol is often used in mathematical operations. It is used to assign a value to a givenvariable. On the other hand, the == symbol, also known as equal to or equivalent to, is a relational operatorthat is used to compare two values.
42.Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
<> is incorrect. While this operator is correctly interpreted as not equal to in writing conditionalstatements, it is not the proper operator to be used in C programming. Instead, the operator != must beused to indicate not equal to condition.
43.Can the curly brackets { } be used to enclose a single line of code?
While curly brackets are mainly used to group several lines of codes, it will still work withouterror if you used it for a single line. Some programmers prefer this method as a way of organizing codes tomake it look clearer, especially in conditional statements.
44.What are header files and what are its uses in C programming?
Header files are also known as library files. They contain two essential things: the definitions andprototypes of functions being used in a program. Simply put, commands that you use in C programmingare actually functions that are defined from within each header files. Each header file contains a set offunctions. For example: stdio.h is a header file that contains definition and prototypes of commands likeprintf and scanf.
45.Can I use int data type to store the value 32768? Why?
No. Int data type is capable of storing values from -32768 to 32767. To store 32768, you can uselong int instead. You can also use unassigned int assuming you don’t intend to store negative values.
46.Can two or more operators such as \n and \t be combined in a single line of program code
Yes, it's perfectly valid to combine operators, especially if the need arises. For example: you canhave a code like printf (Hello\n\n\World\) to output the text Hello on the first line and World enclosed insingle quotes to appear on the next two lines.
47.Why is it that not all header files are declared in every C program?
The choice of declaring a header file at the top of each C program would depend on whatcommands/functions you will be using in that program. Since each header file contains different functiondefinitions and prototype, you would be using only those header files that would contain the functions youwill need. Declaring all header files in every program would only increase the overall file size and load ofthe program, and is not considered a good programming style.
48.When is the void keyword used in a function?
When declaring functions, you will decide whether that function would be returning a value ornot. If that function will not return a value, such as when the purpose of a function is to display someoutputs on the screen, then ?void? is to be placed at the leftmost part of the function header. When a returnvalue is expected after the function execution, the data type of the return value is placed instead of void
49.What are compound statements?
Compound statements are made up of two or more program statements that are executed together.This usually occurs while handling conditions wherein a series of statements are executed when a TRUEor FALSE is evaluated. Compound statements can also be executed within a loop. Curly brackets { } areplaced before and after compound statements.
50.Write a loop statement that will show the following output: 1 12 123 1234 12345
[c]for (a=1; a<=5; i++) {for (b=1; b<=a; b++)printf("%d",b);printf("\n");}[/c]
51.What is wrong in this statement? scanf(%d, whatnumber);
An ampersand & symbol must be placed before the variable name what number. Placing &means whatever integer value is entered by the user is stored at the address of the variable name. This is acommon mistake for programmers, often leading to logical errors.
52.How do you generate random numbers in C?
Random numbers are generated in C using the rand() command. For example: anyNum = rand()will generate any integer number beginning from 0, assuming that anyNum is a variable of type integer.
53.What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
The most probable reason behind this error is that the header file for that function was not indicated at thetop of the program. Header files contain the definition and prototype for functions and commands used in aC program. In the case of tolower(), the code #include <ctype.h>must be present at the beginning of theprogram.
54.What does the format %10.2 mean when included in a printf statement?
This format is used for two things: to set the number of spaces allotted for the output number andto set the number of decimal places. The number before the decimal point is for the allotted space, in thiscase it would allot 10 spaces for the output number. If the number of space occupied by the output numberis less than 10, addition space characters will be inserted before the actual output number. The numberafter the decimal point sets the number of decimal places, in this case, it’s 2 decimal spaces.
55.What is wrong with this statement? myName = Robin;
You cannot use the = sign to assign values to a string variable. Instead, use the strcpy function.The correct statement would be: strcpy(myName, Robin);
56.How do you determine the length of a string value that was stored in a variable?
To get the length of a string value, use the function strlen(). For example, if you have a variablenamed FullName, you can get the length of the stored string value by using this statement: I =strlen(FullName); the variable I will now have the character length of the string value.
57.Is it possible to initialize a variable at the time it was declared?
Yes, you don't have to write a separate assignment statement after the variable declaration, unlessyou plan to change it later on. For example: char planet[15] = Earth does two things: it declares a stringvariable named planet, then initializes it with the value Earth
58.What are the different file extensions involved when programming in C?
Source codes in C are saved with .C file extension. Header files or library files have the .H fileextension. Every time a program source code is successfully compiled, it creates an .OBJ object file, andan executable .EXE file.
59.What are reserved words?
Reserved words are words that are part of the standard C language library. This means thatreserved words have special meaning and therefore cannot be used for purposes other than what it isoriginally intended for. Examples of reserved words are int, void, and return.
60.What are linked list?
A linked list is composed of nodes that are connected with another. In C programming, linkedlists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage.
61.What are binary trees?
Binary trees are actually an extension of the concept of linked lists. A binary tree has twopointers, a left one and a right one. Each side can further branch to form additional nodes, which each nodehaving two pointers as well.
62.Not all reserved words are written in lowercase. TRUE or FALSE?
FALSE. All reserved words must be written in lowercase; otherwise the C compiler wouldinterpret this as unidentified and invalid.
63.What is wrong with this program statement? void = 10;
The word void is a reserved word in C language. You cannot use reserved words as auser-defined variable.
64.Is this program statement valid? INT = 10.50;
Assuming that INT is a variable of type float, this statement is valid. One may think that INT is areserved word and must not be used for other purposes. However, recall that reserved words are express inlowercase, so the C compiler will not interpret this as a reserved word.
65.What is a newline escape sequence?
A newline escape sequence is represented by the \n character. This is used to insert a new linewhen displaying data in the output screen. More spaces can be added by inserting more \n characters. Forexample, \n\n would insert two spaces. A newline escape sequence can be placed before the actual outputexpression or after.
66.What is output redirection?
It is the process of transferring data to an alternative output source other than the display screen.Output redirection allows a program to have its output saved to a file. For example, if you have a programnamed COMPUTE, typing this on the command line as COMPUTE >DATA can accept input from theuser, perform certain computations, then have the output redirected to a file named DATA, instead ofshowing it on the screen.
67.What is the difference between functions abs() and fabs()?
These 2 functions basically perform the same action, which is to get the absolute value of thegiven value. Abs() is used for integer values, while fabs() is used for floating type numbers. Also, theprototype for abs() is under <stdlib.h>, while fabs() is under <math.h>.
68.Write a simple code fragment that will check if a number is positive or negative.
:[c]
If (num>=0)printf("number is positive");elseprintf ("number is negative");[/c]
69.What does the function toupper() do?
It is used to convert any letter to its upper case mode. Toupper() function prototype is declared in<ctype.h>. Note that this function will only convert a single character, and not an entire string.
70.Which function in C can be used to append a string to another string?
The strcat function. It takes two parameters, the source string and the string value to be appendedto the source string.
71.Do these two program statements perform the same output? 1) scanf(?%c?, &letter); 2) letter=getchar()
Yes, they both do the exact same thing, which is to accept the next key pressed by the user andassign it to variable named letter.
72.What is the difference between text files and binary files?
Text files contain data that can easily be understood by humans. It includes letters, numbers andother characters. On the other hand, binary files contain 1s and 0s that only computers can interpret.
73.is it possible to create your own header files?
Yes, it is possible to create a customized header file. Just include in it the function prototypes thatyou want to use in your program, and use the #include directive followed by the name of your header file.
74.What is dynamic data structure?
Dynamic data structure provides a means for storing data more efficiently into memory. Usingdynamic memory allocation, your program will access memory spaces as needed. This is in contrast tostatic data structure, wherein the programmer has to indicate a fix number of memory space to be used inthe program.
75.The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
You can do this by using %% in the printf statement. For example, you can write printf(?10%%?)to have the output appear as 10% on the screen.
76.What are the advantages and disadvantages of a heap?
Storing data on the heap is slower than it would take when using the stack. However, the mainadvantage of using the heap is its flexibility. That’s because memory in this structure can be allocated andremove in any particular order. Slowness in the heap can be compensated if an algorithm was welldesigned and implemented.
77.Explain what objective-C program basically consists of?
Objective-C program basically consists of
78.Explain what is OOP?
OOP means Object Oriented Programming; it is a type of programming technique that helps to manage a setof objects in a system. With the help of various programming languages, this method helps to develop severalcomputer programs and applications.
79.Explain what is the protocol in Objective C?
In Objective-C, a protocol is a language feature, that provides multiple inheritances in a single inheritancelanguage. Objective C supports two types of protocol.
80.Explain what is the difference between polymorphism and abstraction?
Abstraction in OOP is the process of reducing the unwanted data and maintaining only the relevant data forthe users while polymorphism enables an object to execute their functions in two or more forms.
81.Explain what is parsing and mention which class can we use for passing of XML in iphone?
Parsing is the process referred to access the data in the XML element. We can use class “NSXML” parserfor passing XML in iphone.
82.Mention which class are used to establish a connection between applications to the web server?
The class used to establish connection between applications to web server are
83.Explain what is an accessor methods?
Accessor methods are methods belonging to a class that enables you to get and set the values of instancevaluable contained within the class.
84.Explain what is #import?
#import is a C pre-processor construct to avoid multiple inclusions of the same file.
85.Mention what is the class of a constant string?
It’s and NXConstantString. NXConstantString *myString = @ “my string”;
86.List out the methods used in NSURL connection?
Methods used in NSURL connection are
87.Explain class definition in Objective-C?
A class definition begins with the keyword @interface followed by the interface (class) name, and theclass body, closed by a pair of curly braces. In Objective-C, all classed are retrieved from the base classcalled NSObject. It gives basic methods like memory allocation and initialization.
88.Mention what is the use of category in Objective-C?
The use of category in Objective-C is to extend an existing class by appending behavior that is useful onlyin certain situations. In order to add such extension to existing classes, objective –C provides extensionsand categories. The syntax used to define a category is @interface keyword.
89.Explain what are the characteristics of the category?
Characteristics of category includes
class
any sub-classes for the original class
the original class
90.Explain what is single inheritance in Objective-C?
Objective-c subclass can only be obtained from a single direct parent class this concept is known as“single inheritance” .
91.Explain what is polymorphism in Objective-C?
Polymorphism in Objective-C is referred to a capability of base class pointer to call the function.
92.Explain when to use NSArray and NSMutableArray?
NSArray: You will use an NS array when data in the array don’t change. For example, the company nameyou will put in NS Array so that no one can manipulate it.
NSMutableArray: This array will be used in an array, when data in an array will change. For instance, ifyou are passing an array to function and that function will append some elements in that array then youwill choose NSMutable Array.
93.Explain what is synthesized in Objective-C?
Once you have declared the property in objective-C, you have to tell the compiler instantly by usingsynthesize directive. This will tell the compiler to generate a getter & setter message.
94.Explain how string is represented in Objective-C?
In Objective-C, the string is represented by using NSS string and its sub-class NSMutableString providesseveral ways for creating string objects.
95.Explain what is data encapsulation in Objective-C?
In Objective-C, data encapsulation is referred to the mechanism of connecting the data and the functionsthat use them.
96.Explain how to call the function in Objective-C?
To call the function in Objective-C, you have to do Account -> Object Name -> Display accountinformation -> Method name
97.Explain what are objective- C blocks?
In Objective-C class, there is an object that combines data with related behavior. It enables you to formdistinct segments of code that can be passed around to functions or methods as if they were values.Objective-C blocks can be added to collections like NSDictionary or NSArray.
98.Explain what is the main difference between the function calls and messages?
The main difference between function call and message is that a function and its arguments are linkedtogether in the compiled code, but a message and a receiving object are not linked until the program isexecuting and the message is sent.
99.Explain how messaging works in Objective-C?
Messaging are not bound to method implementation until runtime in Objective-C. The compiler transformsa message expression, into a call on a messaging function, objc_msgSend(). This function connects thereceiver and the name of the method mentioned in the message.
100.Explain how the class “IMPLEMENTATION” is represented in Objective-C?
In Objective-C the class “ IMPLEMENTATION” is represented with @implementation directive andends with @end.
101.Explain what is dot notation?
Dot notation involves assessing an instance variable by determining a class “instance” followed by a “dot”followed in turn by the name of instance variable or property to be accessed.
102.Mention whether NS object is a parent class or derived class?
NS object is the parent class and consists of a number of instance variables and instance methods.
103.What is the reuse Identifier used for?
The reuse Identifier is used to indicate that a cell can be reused in a UITableView. For example when thecell looks the same, but has different content. The UITableView will maintain an internal cache ofUITableViewCell’s with the reuse Identifier and allow them to be reused whendequeueReusableCellWithIdentifier: is called. By reusing table cell’s the scroll performance of the tableview is better because new views do not need to be created.
104.Explain the difference between atomic and nonatomic synthesized properties?
Atomic and nonatomic refers to whether the setters/getters for a property will atomically read and writevalues to the property. When the atomic keyword is used on a property, any access to it will be“synchronized”. Therefore a call to the getter will be guaranteed to return a valid value, however this doescome with a small performance penalty. Hence in some situations nonatomic is used to provide fasteraccess to a property, but there is a chance of a race condition causing the property to be nil under rarecircumstances (when a value is being set from another thread and the old value was released from memorybut the new value hasn’t yet been fully assigned to the location in memory for the property).
105.Explain the difference between copy and retain?
Retaining an object means the retain count increases by one. This means the instance of the object will bekept in memory until it’s retain count drops to zero. The property will store a reference to this instance andwill share the same instance with anyone else who retained it too. Copy means the object will be clonedwith duplicate values. It is not shared with any one else.
106.What’s the difference between not running, inactive, active, background and suspended execution states?
Not running: The app has not been launched or was running but was terminated by the system.
Inactive: The app is running in the foreground but is currently not receiving events. (It may be executingother code though.) An app usually stays in this state only briefly as it transitions to a different state.
Active: The app is running in the foreground and is receiving events. This is the normal mode forforeground apps.
Background: The app is in the background and executing code. Most apps enter this state briefly on theirway to being suspended. However, an app that requests extra execution time may remain in this state for aperiod of time. In addition, an app being launched directly into the background enters this state instead ofthe extra execution time may remain in this state for a period of time. In addition, an app being launcheddirectly into the background enters this state instead of the inactive state.
Suspended: The app is in the background but is not executing code. The system moves apps to this stateautomatically and does not notify them before doing so. While suspended, an app remains in memory butdoes not execute any code. When a low memory condition occurs, the system may purge suspended appswithout notice to make more space for the foreground app.
107.What is a category and when is it used?
A category is a way of adding additional methods to a class without extending it. It is often used to add acollection of related methods. A common use case is to add additional methods to built in classes in theCocoa frameworks. For example adding async download methods to the UIImage class.
108.What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view?
viewDidLoad is called when the view is loaded, whether from a Xib file, storyboard or programmaticallycreated in loadView. viewDidAppear is called every time the view is presented on the device. Which touse depends on the use case for your data. If the data is fairly static and not likely to change then it can beloaded in viewDidLoad and cached. However if the data changes regularly then using viewDidAppear toload it is better. In both situations, the data should be loaded asynchronously on a background thread toavoid blocking the UI.
109.What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server?
This is a very common task in iOS and a good answer here can cover a whole host of knowledge. Theimportant piece of information in the question is that the images are hosted remotely and they may taketime to download, therefore when it asks for “considerations”, you should be talking about:
keep scrolling.
been reused by another piece of data. If it’s been reused then we should discard the image, otherwise weneed to switch back to the main thread to change the image on the cell.
110.What is a protocol, how do you define your own and when is it used?
A protocol is similar to an interface from Java. It defines a list of required and optional methods that aclass must/can implement if it adopts the protocol. Any class can implement a protocol and other classescan then send messages to that class based on the protocol methods without it knowing the type of theclass.
@protocol MyCustomDataSource
? (NSUInteger)numberOfRecords;
? (NSDictionary *)recordAtIndex:(NSUInteger)index;
@optional
? (NSString *)titleForRecordAtIndex:(NSUInteger)index;
@end
A common use case is providing a DataSource for UITableView or UICollectionView.
111.What is the Responder Chain?
When an event happens in a view, for example a touch event, the view will fire the event to a chain ofUIResponder objects associated with the UIView. The first UIResponder is the UIView itself, if it does nothandle the event then it continues up the chain to until UIResponder handles the event. The chain willinclude UIViewControllers, parent UIViews and their associated UIViewControllers, if none of thosehandle the event then the UIWindow is asked if it can handle it and finally if that doesn't handle the eventthen the UIApplicationDelegate is asked.
112.How would you create your own custom view?
By Subclassing the UIView class.
113.What is fast enumeration?
Fast enumeration is a language feature that allows you to enumerate over the contents of a collection.(Your code will also run faster because the internal implementation reduces message send overhead andincreases pipelining potential.)
114.What is a struct?
A struct is a special C data type that encapsulates other pieces of data into a single cohesive unit. Like anobject, but built into C.
115.What are mutable and immutable types in Objective C?
Mutable means you can change its contents later but when you mark any object immutable, it means oncethey are initialized, their values cannot be changed. For example, NSArray, NSString values cannot bechanged after initialized.
116.Explain retain counts?
Retain counts are the way in which memory is managed in Objective?C. When you create an object, it hasa retain count of 1. When you send an object a retain message, its retain count is incremented by 1. Whenyou send an object a release message, its retain count is decremented by 1. When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. If an objects retain countis reduced to 0, it is de allocated.
117.What is the difference between frame and bounds?
The frame of a view is the rectangle, expressed as a location (x,y) and size (width, height) relative to thesuper view it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) andsize (width, height) relative to its own coordinate system (0,0).
118.Is a delegate retained?
No, the delegate is never retained! Ever!
119.If I call performSelector:withObject:afterDelay: – is the object retained?
Yes, the object is retained. It creates a timer that calls a selector on the current threads run loop. It may notbe 100% precise time wise as it attempts to dequeue the message from the run loop and perform theselector.
120.Can you explain what happens when you call auto release on an object?
When you send an object a auto release message, its retain count is decremented by 1 at some stage in thefuture. The object is added to an auto release pool on the current thread. The main thread loop creates anauto release pool at the beginning of the function, and release it at the end. This establishes a pool for thelifetime of the task. However, this also means that any auto released objects created during the lifetime ofthe task are not disposed of until the task completes. This may lead to the task's memory footprintincreasing unnecessarily. You can also consider creating pools with a narrower scope or useNSOperationQueue with it?s own auto release pool. (Also important – You only release or auto releaseobjects you own.)
121.What is the NSCoder class used for?
NSCoder is an abstract Class which represents a stream of data. They are used in Archiving andUnarchiving objects. NSCoder objects are usually used in a method that is being implemented so that theclass conforms to the protocol. (which has something like encode Object and decode Object methods inthem).
122.What is an NSOperationQueue and how/would you use it?
The NSOperationQueue class regulates the execution of a set of NSOperation objects. An operation queueis generally used to perform some asynchronous operations on a background thread so as not to block themain thread.
123.Explain the correct way to manage Outlets memory
Create them as properties in the header that are retained. In the viewDidUnload set the outlets to nil(i.eself.outlet = nil). Finally in dealloc make sure to release the outlet.
124.Is the delegate for a CAAnimation retained?
Yes it is!! This is one of the rare exceptions to memory management rules.
125.Explain the difference between NSOperationQueue concurrent and non?concurrent.
In the context of an NSOperation object, which runs in an NSOperationQueue, the terms concurrent andnonconcurrent do not necessarily refer to the side?by?side execution of threads. Instead, a non?concurrentoperation is one that executes using the environment that is provided for it while a concurrent operation isresponsible for setting up its own execution environment.
126.What is Automatic Reference Counting (ARC) ?
ARC is a compiler?level feature that simplifies the process of managing the lifetimes of Objective?Cobjects. Instead of you having to remember when to retain or release an object, ARC evaluates the lifetimerequirements of your objects and automatically inserts the appropriate method calls at compile time.
127.What is the difference between delegates and notifications?
We can use notifications for a variety of reasons. For example, you could broadcast a notification tochange how user?interface elements display information based on a certain event elsewhere in the program.Or you could use notifications as a way to ensure that objects in a document save their state before thedocument window is closed. The general purpose of notifications is to inform other objects of programevents so they can respond appropriately. But objects receiving notifications can react only after the eventhas occurred. This is a significant difference from delegation. The delegate is given a chance to reject ormodify the operation proposed by the delegating object. Observing objects, on the other hand, cannotdirectly affect an impending operation.
128.Where can you test Apple iPhone apps if you don’t have the device?
iOS Simulator can be used to test mobile applications. Xcode tool that comes along with iOS SDKincludes Xcode IDE as well as the iOS Simulator. Xcode also includes all required tools and frameworksfor building iOS apps. However, it is strongly recommended to test the app on the real device beforepublishing it.
129.Which JSON framework is supported by iOS?
SBJson framework is supported by iOS. It is a JSON parser and generator for Objective?C. SBJsonprovides flexible APIs and additional control that makes JSON handling easier.
130.What are the tools required to develop iOS applications?
iOS development requires Intel based Macintosh computer and iOS SDK.
131.Name the framework that is used to construct application’s user interface for iOS.
The UIKit framework is used to develop application’s user interface for iOS. UI kit framework providesevent handling, drawing model, windows, views, and controls specifically designed for a touch screeninterface.
132.What is C#?
C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. Itwill immediately be familiar to C and C++ programmers. C# combines the high productivity of RapidApplication Development (RAD) languages.
133.What are the types of comment in C#?
There are 3 types of comments in C#.
134.What are the namespaces used in C#.NET?
Namespace is a logical grouping of class.
135.What are the characteristics of C#?
There are several characteristics of C# are:
136.What are the different categories of inheritance?
Inheritance in Object Oriented Programming is of four types:
137.Can you inherit multiple interfaces?
Yes. Multiple interfaces may be inherited in C#.
138.What is inheritance?
Inheritance is deriving the new class from the already existing one.
139.Define scope?
Scope refers to the region of code in which a variable may be accessed.
140.What is the difference between public, static and void?
Public: The keyword public is an access modifier that tells the C# compiler that the main method isaccessible by anyone
Static: The keyword static declares that the Main method is a global one and can be called without creatingan instance of the class. The compiler stores the address of the method as the entry point and uses thisinformation to begin execution before any objects are created.
Void: The keyword void is a type modifier that states that the Main method does not return any value.
141.What are the modifiers in C#?
142.What are the types of access modifiers in C#?
Access modifiers in C# are:
143.What is boxing and unboxing?
Implicit conversion of value type to reference type of a variable is known as BOXING, for exampleinteger to object type conversion. Conversion of reference type variable back to value type is called asUnboxing.
144.What is object?
An object is an instance of a class. An object is created by using operator new. A class that creates anobject in memory will contain the information about the values and behaviors (or methods) of that specificobject.
145.Where are the types of arrays in C#?
146.What is the difference between Object and Instance?
An instance of a user defined type is called an object. We can instantiate many objects from one class. Anobject is an instance of a class.
147.Define destructors?
A destructor is called for a class object when that object passes out of scope or is explicitly deleted. Adestructors as the name implies is used to destroy the objects that have been created by a constructors. Likea constructor, the destructor is a member function whose name is the same as the class name but isprecised by a tilde.
148.What is the use of enumerated data type?
An enumerated data type is another user defined type which provides a way for attaching names tonumbers thereby increasing comprehensibility of the code. The enum keyword automatically enumerates alist of words by assigning those values 0, 1, 2, and so on.
149.Define Constructors?
A constructor is a member function with the same name as its class. The constructor is invoked wheneveran object of its associated class is created. It is called constructor because it constructs the values of datamembers of the class.
150.What is encapsulation?
The wrapping up of data and functions into a single unit (called class) is known a encapsulation.Encapsulation containing and hiding information about an object, such as internal data structures and code.
151.Does c# support multiple inheritance?
No, it’s impossible which accepts multi level inheritance.
152.What is ENUM
Enum are used to define constants.
153.What is a data set?
A Dataset is an in memory representation of data loaded from any data source.
154.What is the difference between private and public keyword?
Private: The private keyword is the default access level and most restrictive among all other access levels.It gives least permission to a type or type member. A private member is accessible only within the body ofthe class in which it is declared.
Public: The public keyword is most liberal among all access levels, with no restrictions to access what soever. A public member is accessible not only from within, but also from outside, and gives free access toany member declared within the body or outside the body.
155.Define polymorphism?
Polymorphism means one name, multiple forms. It allows us to have more than one function with the samename in a program. It allows us to have overloading of operators so that an operation can exhibit differentbehaviors in different instances.
156.What is Jagged Arrays?
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of differentdimensions and sizes. A jagged array is sometimes called an array–of–arrays.
157.What is an abstract base class?
An abstract class is a class that is designed to be specifically used as a base class. An abstract classcontains at least one pure virtual function.
158.How is method overriding different from method overloading?
When overriding a method, you change the behavior of the method for the derived class. Overloading amethod simply involves having another method with the same name within the class.
159.What is the difference between ref & out parameters?
An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whoseargument does not have to be explicitly initialized before being passed an out parameter.
160.What is the use of using statement in C#?
The using statement is used to obtain a resource, execute a statement, and then dispose of that resource.
161.What are the difference between Structure and Class?
162.What is difference between Class And Interface?
Class is logical representation of object. It is collection of data and related sub procedures with definition.Interface is also a class contain methods which is not having any definitions. Class does not supportmultiple inheritance. But interface can support.
163.What is Delegates?
Delegates are a type safe, object-oriented implementation of function pointers and are used in manysituations where a component needs to call back to the component that is using it.
164.What is Authentication and Authorization?
Authentication is the process of identifying users. Authentication is identifying/validating the user againstthe credentials (username and password). Authorization performs after authentication. Authorization is theprocess of granting access to those users based on identity. Authorization allowing access of specificresource to user.
165.What is a base class?
A class declaration may specify a base class by following the class name with a colon and the name of thebase class. omitting a base class specification is the same as deriving from type object.
166.Can “this” be used within a static method?
No ‘This’ cannot be used in a static method. As only static variables/methods can be used in a staticmethod.
167.What is difference between constants, read-only and, static ?
168.What are the different types of statements supported in C#?
C# supports several different kinds of statements are
Block statements
Declaration statements
Expression statements
Selection statements
Iteration statements
Jump statements
Try catch statements
Checked and unchecked
Lock statement
169.What is an interface class?
It is an abstract class with public abstract methods all of which must be implemented in the inheritedclasses.
170.What are value types and reference types?
Value types are stored in the Stack.
Examples : bolo, byte, chat, decimal, double, enema , float, into, long, byte, short, strut, unit, along, short.
Reference types are stored in the Heap.
Examples : class, delegate, interface, object, string.
171.What is the difference between string keyword and System.String class?
String keyword is an alias for Syste.String class. Therefore, System.String and string keyword are thesame, and you can use whichever naming convention you prefer. The String class provides many methodsfor safely creating, manipulating, and comparing strings.
172.What are the two data types available in C#?
Value typeReference type
173.What are the different types of Caching?
There are three types of Caching:
174.What is the difference between Custom Control and User Control?
Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox.Drag and Drop controls.
Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even ifPrivate can copy to bin directory of web application add reference and use. Normally designed to providecommon functionality independent of consuming Application.
User Controls are similar to those of ASP include files, easy to create, can not be placed in the toolbox anddragged dropped from it. A User Control is shared among the single application files.
175.What is methods?
A method is a member that implements a computation or action that can be performed by an object orclass. Static methods are accessed through the class. Instance methods are accessed through instances ofthe class.
176.What is fields?
A field is a variable that is associated with a class or with an instance of a class.
177.What is literals and their types?
Literals are value constants assigned to variables in a program. C# supports several types of literals are
178.What is the difference between value type and reference type?
Value types are stored on the stack and when a value of a variable is assigned to another variable.
Reference types are stored on the heap, and when an assignment between two reference variables occurs.
179.What are the features of c#?
C# is a simple and powerful programming language for writing enterprise edition applications. This is ahybrid of C++ and VB. It retains many C++ features in the area statements, expressions, and operators andincorporated the productivity of VB. C# helps the developers to easily build the web services that can beused across the Internet through any language, on any platform.C# helps the developers accomplishingwith fewer lines of code that will lead to the fewer errors in the code. C# introduces the considerableimprovement and innovations in areas such as type safety, versioning. events and garbage collections.
180.What are the types of errors?
181.What is the difference between break and continue statement?
The break statement is used to terminate the current enclosing loop or conditional statements in which itappears. We have already used the break statement to come out of switch statements. The continuestatement is used to alter the sequence of execution. Instead of coming out of the loop like the breakstatement did, the continue statement stops the current iteration and simply returns control back to the topof the loop.
182.Define namespace?
The namespace are known as containers which will be used to organize the hierarchical set of .NETclasses.
183.What is a code group?
A code group is a set of assemblies that share a security context.
184.What are sealed classes in C#?
The sealed modifier is used to prevent derivation from a class. A compile time error occurs if a sealed classis specified as the base class of another class.
185.What is the difference between static and instance methods?
A method declared with a static modifier is a static method. A static method does not operate on a specificinstance and can only access static members. A method declared without a static modifier is an instancemethod. An instance method operates on a specific instance and can access both static and instancemembers. The instance on which an instance method was invoked can be explicitly accessed as this. It isan error to refer to this in a static method.
186.What are the different types of variables in C#?
Different types of variables used in C# are :
187.What is meant by method overloading?
Method overloading permits multiple methods in the same class to have the same name as long as theyhave unique signatures. When compiling an invocation of an overloaded method, the compiler usesoverload resolution to determine the specific method to invoke.
188.What is parameters?
Parameters are used to pass values or variable references to methods. The parameters of a method get theiractual values from the arguments that are specified when the method is invoked. There are four kinds ofparameters: value parameters, reference parameters, output parameters, and parameter arrays.
189.Is C# is object oriented?
Yes, C# is an OO language in the tradition of Java and C++.
190.What is the difference between Array and Array list?
An array is a collection of the same type. The size of the array is fixed in its declaration. A linked list issimilar to an array but it doesn’t have a limited size.
191.What are the special operators in C#?
C# supports the following special operators.
is (relational operator)
as (relational operator)
typeof (type operator)
sizeof (size operator)
new (object creator)
.dot (member access operator)
checked (overflow checking)
unchecked (prevention of overflow checking)
192.What is meant by operators in c#?
An operator is a member that defines the meaning of applying a particular expression operator to instancesof a class. Three kinds of operators can be defined: unary operators, binary operators, and conversionoperators. All operators must be declared as public and static.
193.What is a parameterized type?
A parameterized type is a type that is parameterized over another value or type.
194.What are the features of abstract class?
An abstract class cannot be instantiated, and it is an error to use the new operator on an abstract class. Anabstract class is permitted (but not required) to contain abstract methods and accessors. An abstract classcannot be scaled.
195.What is the use of abstract keyword?
The modifier abstract is a keyword used with a class, to indicate that this class cannot itself have directinstances or objects, and it is intended to be only a 'base' class to other classes.
196.What is the use of goto statement?
The goto statement is also included in the C# language. This goto can be used to jump from inside a loop tooutside. But jumping from outside to inside a loop is not allowed.
197.What is the difference between console and window application?
A console application, which is designed to run at the command line with no user interface. A Windowsapplication, which is designed to run on a user’s desktop and has a user interface.
198.What is the use of return statement?
The return statement is associated with procedures (methods or functions). On executing the returnstatement, the system passes the control from the called procedure to the calling procedure. This returnstatement is used for two purposes :
to return immediately to the caller of the currently executed code
to return some value to the caller of the currently executed code.
199.What is the difference between Array and Linked List?
Array is a simple sequence of numbers which are not concerned about each others positions. they areindependent of each others positions. adding, removing or modifying any array element is very easy.Compared to arrays ,linked list is a complicated sequence of numbers.
200.Does C# have a throws clause?
No, unlike Java, C# does not require the developer to specify the exceptions that a method can throw.
201.Does C# support a variable number of arguments?
Yes, using the params keyword. The arguments are specified as a list of arguments of a specific type.
202.Can you override private virtual methods?
No, private methods are not accessible outside the class.
203.What is a multi cast delegates?
Each delegate object holds reference to a single method. However, it is possible for a delegate object tohold references of and invoke multiple methods. Such delegate objects are called multicast delegates orcombinable delegates.
204.Which is an exclusive feature of C#?
Xml documentation.
205.Is using of exceptions in C# recommended?
Yes, exceptions are the recommended error handling mechanism in .NET Framework.
206.What does a break statement do in switch statements?
The break statement terminates the loop in which it exists. It also changes the flow of the execution of aprogram. In switch statements, the break statement is used at the end of a case statement. The breakstatement is mandatory in C# and it avoids the fall through of one case statement to another.
207.Is C# object oriented?
Yes, C# is an OO language in the tradition of java and C++.
208.What is smart navigation?
The cursor position is maintained when the page gets refreshed due to the server side validation and thepage gets refreshed.
209.What is the difference between CONST and READONLY?
Both are meant for constant values. A const field can only be initialized at the declaration of the field. Aread-only field can be initialized either at the declaration or.
210.Does C# have a throws clause?
No, unlike Java, C# does not require (or even allow) the developer to specify the exceptions that a methodcan throw.
211.What are the different ways a method can be overloaded?
Different parameter data types, different number of parameters, different order of parameters.
212.Do events have return type?
No, events do not have return type.
213.What is event?
An event is an action performed based on another method of the program. An event is a delegate type dassmember that is used by an object or a class to provide a notification to other objects that an event hasoccurred. An event can be declared with the help of the event keyword.
214.What is an identifier?
Identifiers are nothing but names given to various entities uniquely identified in a program.
215.What are the different types of literals in C#?
Boolean literals: True and False are literals of the Boolean type that map to the true and false state,respectively
Integer literals: Used to write values of types Int, ulnt, long, and ulong.
Real literals: Used to write values of types float, double, and dedmal.
Character literals: Represents a single character and usually consists of a character in quotes, such as 'a'.
String literals: C# supports two types of string literals, regular string literal and verbatim string literals. Aregular string literal consists of zero or more characters enclosed in double quotes, such as "116110". Averbatim string literal consists of an @ character followed by a double–quote character, such as ©"hello".
The Null literal: Represents the null–type.
216.What is meant by data encapsulation?
Data encapsulation, also referred to as data hiding, is the mechanism whereby the implementation details ofa class are kept hidden from the user. The user can only perform a restricted set of operations on the hiddenmembers of the class by executing special functions called methods.
217.Can you override private virtual methods?
No. Private methods are not accessible outside the class.
218.What is the main difference between a sub procedure and a function
Sub procedures do not return a value, while functions do.
219.How does C# differ from C++?
C# does not support #include statement. It uses only using statement. In C# , class definition does not use asemicolon at the end. C# does not support multiple code inheritance. Casting in C# is much safer than inc++. In C# switch can also be used on string values Command line parameters array behave differently inC# as compared to C++.
220.What is nested class?
A Nested classes are classes within classes. A nested class is any class whose declaration occurs within thebody of another class or interface.
221.Can you have parameters for static constructors?
No, static constructors cannot have parameters.
222.Is String is Value Type or Reference Type in C#?
String is an object(Reference Type).
223.Does C# provide copy constructor?
No, C# does not provide copy constructor.
224.Can you create an instance of an interface?
No, you cannot create an instance of an interface.
225.Can an Interface contain fields?
No, an Interface cannot contain fields.
226.Can a class have static constructor?
Yes, a class can have static constructor. Static constructors are called automatically, immediately beforeany static fields are accessed, and are generally used to initialize static class members. It is calledautomatically before the first instance is created or any static members are referenced. Static constructorsare called before instance constructors.