

MCQOPTIONS
Saved Bookmarks
This section includes 151 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
The library function used to reverse a string is |
A. | strstr() |
B. | strrev() |
C. | revstr() |
D. | strreverse() |
Answer» C. revstr() | |
2. |
If and bytes size, What will be the output of the program ? |
A. | 1, 2, 4 |
B. | 1, 4, 4 |
C. | 2, 2, 4 |
D. | 2, 4, 8 |
Answer» C. 2, 2, 4 | |
3. |
For the following statements will and fetch the same character? |
A. | Yes |
B. | No |
Answer» B. No | |
4. |
Which of the following statements are correct about the below declarations? |
A. | 1, 2 |
B. | 2, 3, 4 |
C. | 3, 4 |
D. | 2, 3 |
Answer» C. 3, 4 | |
5. |
Is there any difference between the two statements? |
A. | Yes |
B. | No |
Answer» B. No | |
6. |
If the two strings are identical, then function returns |
A. | -1 |
B. | 1 |
C. | 0 |
D. | Yes |
Answer» D. Yes | |
7. |
What will be the output of the following C code?
|
A. | hello |
B. | Interveiw, Mania |
C. | 24 |
D. | Compilation Error |
E. | None of these |
Answer» D. Compilation Error | |
8. |
What will be the output of the following C code?
|
A. | Segmentation fault |
B. | Compilation Error |
C. | Nothing |
D. | hello, Interview, Mania 23 |
E. | None of these |
Answer» E. None of these | |
9. |
What will be the output of the following C code?
|
A. | hello |
B. | Interview Mania |
C. | hello Interview Mania |
D. | hello Interview |
E. | None of these |
Answer» D. hello Interview | |
10. |
What will be the output of the following C code?
|
A. | Interview |
B. | Interview Mania 0 |
C. | Mania |
D. | Compilation Error |
E. | None of these |
Answer» C. Mania | |
11. |
What will be the output of the following C code?
|
A. | R |
B. | Compilation Error |
C. | V |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
12. |
What will be the value of var for the following C statement?
|
A. | strcmp has void return-type |
B. | 1 |
C. | 0 |
D. | -1 |
E. | None of these |
Answer» E. None of these | |
13. |
What will be the output of the following C code?
|
A. | Compilation Error |
B. | 25 |
C. | Digit |
D. | Not Digit |
E. | None of these |
Answer» D. Not Digit | |
14. |
What will be the output of the following C code?
|
A. | B |
B. | Not Digit |
C. | Compilation Error |
D. | Digit |
E. | None of these |
Answer» C. Compilation Error | |
15. |
What will be the output of the following C code?
|
A. | 20 |
B. | Digit |
C. | Compilation Error |
D. | Not Digit |
E. | None of these |
Answer» E. None of these | |
16. |
The following C expression can be substituted for?
|
A. | if (isalphanum(c)) |
B. | if (isalphanumeric(c)) |
C. | if (isalnum(c)) |
D. | All of above |
E. | None of these |
Answer» F. | |
17. |
Which is true about isalnum(ch), where ch is an int that can be represented as an unsigned?
|
A. | Nothing |
B. | 0 if not isalpha(ch) or not isdigit(ch) |
C. | Non-zero if isalpha(ch) or isdigit(ch) |
D. | Both 0 if not isalpha(ch) or not isdigit(ch) & Non-zero if isalpha(ch) or isdigit(ch) |
E. | None of these |
Answer» E. None of these | |
18. |
Which is true about isupper(ch), where ch is an int that can be represented as an unsigned?
|
A. | 0 if ch is not upper case |
B. | Non-zero if ch is upper case |
C. | Both 0 if ch is not upper case & Non-zero if ch is upper case |
D. | Nothing |
E. | None of these |
Answer» D. Nothing | |
19. |
Which is true about isaplpha(ch), where ch is an int that can be represented as an unsigned?
|
A. | 0 if ch is not alphabetic |
B. | Non-zero if ch is alphabetic |
C. | Both 0 if ch is not alphabetic & Non-zero if ch is alphabetic |
D. | Non-zero if d is alphabetic |
E. | None of these |
Answer» D. Non-zero if d is alphabetic | |
20. |
What will be the output of the following C code?
|
A. | Compilation Error |
B. | Space |
C. | Garbage value |
D. | Not Space |
E. | None of these |
Answer» C. Garbage value | |
21. |
What will be the output of the following C code?
|
A. | Compilation Error |
B. | 15 |
C. | Not Space |
D. | Space |
E. | None of these |
Answer» D. Space | |
22. |
What will be the output of the following C code?
|
A. | Segmentation fault |
B. | Compilation Error |
C. | Interview, Mania |
D. | hello Interview Mania |
E. | None of these |
Answer» B. Compilation Error | |
23. |
What will be the output of the following C code?
|
A. | Compilation Error |
B. | Equal |
C. | Garbage value |
D. | Not Equal |
E. | None of these |
Answer» E. None of these | |
24. |
Read the following program.
|
A. | even palindrome |
B. | odd palindrome |
C. | both even and odd |
D. | none of the above |
Answer» D. none of the above | |
25. |
What will be the output of the following C code?
|
A. | I |
B. | Compilation Error |
C. | is : w |
D. | W |
E. | None of these |
Answer» D. W | |
26. |
What will be the output of the following C code?
|
A. | I |
B. | Compilation Error |
C. | Non-zero number |
D. | Nothing |
E. | None of these |
Answer» D. Nothing | |
27. |
Which of the following is correct way to convert a String to an int? String s = "123"; int i; i = (int)s; String s = "123"; int i; i = int.Parse(s); String s = "123"; int i; i = Int32.Parse(s); String s = "123"; int i; i = Convert.ToInt32(s); String s = "123"; int i; i = CInt(s); |
A. | 1, 3, 5 |
B. | 2, 4 |
C. | 3, 5 |
D. | 2, 3, 4 |
Answer» E. | |
28. |
Which of the following snippets are the correct way to convert a Single into a String? Single f = 9.8f; String s; s = (String) (f); Single f = 9.8f; String s; s = Convert.ToString(f); Single f = 9.8f; String s; s = f.ToString(); Single f = 9.8f; String s; s = Clnt(f); Single f = 9.8f; String s; s = CString(f); |
A. | 1, 2 |
B. | 2, 3 |
C. | 1, 3, 5 |
D. | 2, 4 |
Answer» C. 1, 3, 5 | |
29. |
Which of the following statements are correct about the String Class in C#.NET? Two strings can be concatenated by using an expression of the form s3 = s1 + s2; String is a primitive in C#.NET. A string built using StringBuilder Class is Mutable. A string built using String Class is Immutable. Two strings can be concatenated by using an expression of the form s3 = s1&s2; |
A. | 1, 2, 5 |
B. | 2, 4 |
C. | 1, 3, 4 |
D. | 3, 5 |
Answer» D. 3, 5 | |
30. |
If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal? if(s1 = s2) if(s1 == s2) int c; c = s1.CompareTo(s2); if( strcmp(s1, s2) ) if (s1 is s2) |
A. | 1, 2 |
B. | 2, 3 |
C. | 4, 5 |
D. | 3, 5 |
Answer» C. 4, 5 | |
31. |
Which of the following statements are true about the C#.NET code snippet given below? String s1, s2; s1 = "Hi"; s2 = "Hi";String objects cannot be created without using new. Only one object will get created. s1 and s2 both will refer to the same object. Two objects will get created, one pointed to by s1 and another pointed to by s2. s1 and s2 are references to the same object. |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 3, 4 |
D. | 2, 5 |
Answer» C. 3, 4 | |
32. |
Which of the following statements are correct? String is a value type. String literals can contain any character literal including escape sequences. The equality operators are defined to compare the values of string objects as well as references. Attempting to access a character that is outside the bounds of the string results in an IndexOutOfRangeException. The contents of a string object can be changed after the object is created. |
A. | 1, 3 |
B. | 3, 5 |
C. | 2, 4 |
D. | 1, 2, 4 |
Answer» D. 1, 2, 4 | |
33. |
If the size of pointer is 32 bits What will be the output of the program ?_x000D_
#include
|
A. | 10, 22, 2 |
B. | 10, 41, 2 |
C. | 11, 41, 1 |
D. | 12, 22, 2 |
Answer» D. 12, 22, 2 | |
34. |
Which of the following statements are correct about the below declarations?_x000D_ char *p = "Sanjay";char a[] = "Sanjay";_x000D_ _x000D_ _x000D_ 1:_x000D_ There is no difference in the declarations and both serve the same purpose._x000D_ _x000D_ _x000D_ 2:_x000D_ p is a non-const pointer pointing to a non-const string, whereas a is a const pointer pointing to a non-const pointer._x000D_ _x000D_ _x000D_ 3:_x000D_ The pointer p can be modified to point to another string, whereas the individual characters within array a can be changed._x000D_ _x000D_ _x000D_ 4:_x000D_ In both cases the '\0' will be added at the end of the string "Sanjay". |
A. | 1, 2 |
B. | 2, 3, 4 |
C. | 3, 4 |
D. | 2, 3 |
Answer» C. 3, 4 | |
35. |
What will be the output of the program ?_x000D_
#include
|
A. | Suresh, Siva, Sona, Baiju, Ritu |
B. | Suresh, Siva, Sona, Ritu, Baiju |
C. | Suresh, Siva, Baiju, Sona, Ritu |
D. | Suresh, Siva, Ritu, Sona, Baiju |
Answer» C. Suresh, Siva, Baiju, Sona, Ritu | |
36. |
Which of the following statements are correct about the program below?
#include
|
A. | The code converts a string in to an integer |
B. | The code converts lower case character to upper case |
C. | The code converts upper case character to lower case |
D. | Error in code |
Answer» C. The code converts upper case character to lower case | |
37. |
What will be the output of the program ?_x000D_
#include
|
A. | Kagpur, Kanpur |
B. | Nagpur, Kanpur |
C. | Kagpur, anpur |
D. | Error |
Answer» E. | |
38. |
What will be the output of the program ?_x000D_
#include
|
A. | t, t |
B. | k, k |
C. | n, k |
D. | m, f |
Answer» C. n, k | |
39. |
What will be the output of the program ?_x000D_
#include
|
A. | A |
B. | a |
C. | c |
D. | 65 |
Answer» B. a | |
40. |
What will be the output of the program ?_x000D_
#include
|
A. | The string is empty |
B. | The string is not empty |
C. | No output |
D. | 0 |
Answer» C. No output | |
41. |
For the following statements will arr[3] and ptr[3] fetch the same character?_x000D_ char arr[] = "IndiaBIX";char *ptr = "IndiaBIX"; |
A. | Yes |
B. | No |
Answer» B. No | |
42. |
Determine output:public class Test{public static void main(String args[]){String str = null;if(str.length() == 0){System.out.print("1");}else if(str == null){System.out.print("2");}else{System.out.print("3");}}} |
A. | ompilation fails. |
B. | 1" is printed. |
C. | 2" is printed. |
D. | 3" is printed. |
E. | n exception is thrown at runtime. |
Answer» F. | |
43. |
What will be the output?1. public class Test{2.public static void main(String args[]){3.Object myObj = new String[]{"one", "two", "three"};4.{5.for(String s : (String[])myObj)6.System.out.print(s + ".");7.}8.}9. } |
A. | ne.two.three. |
B. | ompilation fails because of an error at line 3 |
C. | ompilation fails because of an error at line 5 |
D. | n exception is thrown at runtime. |
E. | one of these |
Answer» B. ompilation fails because of an error at line 3 | |
44. |
What will be the output of the following program code?public class Test{public static void main(String args[]){String s = "what";StringBuffer sb = new StringBuffer("what");System.out.print(sb.equals(s)+","+s.equals(sb));}} |
A. | rue,true |
B. | alse,true |
C. | rue,false |
D. | alse,false |
E. | one of these |
Answer» E. one of these | |
45. |
What will be output?String S1 = "S1 ="+ "123"+"456";String S2 = "S2 ="+(123+456); |
A. | 1=123456, S2=579 |
B. | 1=123456,S2=123456 |
C. | 1=579,S2=579 |
D. | one of This |
Answer» B. 1=123456,S2=123456 | |
46. |
What will be the output?public class Test{public static void main (String[] args){String test = "a1b2c3";String[] tokens = test.split("\\d");for(String s: tokens)System.out.print(s);}} |
A. | bc |
B. | 23 |
C. | untime exception thrown |
D. | ompilation error |
Answer» B. 23 | |
47. |
What will be the output of the following program?public class Test{public static void main(String args[]){String str1 = "one";String str2 = "two";System.out.println(str1.concat(str2));}} |
A. | ne |
B. | wo |
C. | netwo |
D. | woone |
E. | one of these |
Answer» D. woone | |
48. |
What will be the output?String str1 = "abcde";System.out.println(str1.substring(1, 3)); |
A. | bc |
B. | c |
C. | cd |
D. | bcd |
E. | one of these |
Answer» C. cd | |
49. |
The String method compareTo() returns |
A. | rue |
B. | alse |
C. | n int value |
D. | |
Answer» D. | |
50. |
toString() method is defined in |
A. | ava.lang.String |
B. | ava.lang.Object |
C. | ava.lang.util |
D. | one of these |
Answer» C. ava.lang.util | |