Professional Documents
Culture Documents
SPECIFIC MCQS
• If call to library function - int no=strcmp(src,dest),
then value of "no" will be negative when
a) dest > src
b) src>dest
c) there is an error
a) O(n²)
b) O(n³)
c) O(nLogn)
d) O(Logn)
• When rear! = Max-1 in a queue, you can perform
__________ operation.
a) insertion
b) deletion
c) queue is full
d) queue is empty
• Consider a circular queue, where FRONT=MAX-1
and then a dequeue operation has been performed.
a) 0
b) -1
c) 1
d) 2
• What happens to the stack pointer when you pop
an element from a bottom-up stack?
a) Decremented by 1
b) incremented by 1
c) Decremented by 2
d) incremented by 2
• The expression "a=a%2" can also be expressed as
a) a=%2
b) a%=2
c) a=2%a
d) a%2
• Find the output of the following code
#include <iostream>
using namespace std;
int main()
{
int y[] = {3, 00, 6, 4, 56};
int *p = (y + 4);
cout << *p;
return 0;
}
• a) 56 b) 0 c) 3, 00, 6, 4, 56 d) 3006456
• When both the strings are same strcmp, then the
library function will return
b) error
c) zero
b) stringlen()
c) length()
d) strlength()
• What is the output of the following code?
int sum = 0;
int[][] table = {{3,4,5,6},{7,8,9,10}};
for(int x[] : table)
{
for(int y : x)
{
sum += y;
}
}
System.out.println(sum);
• a) 25 b) 52 c) 8 d) Compilation error
• Which of the following is the correct statement
about final classes in Java?
int x=10;
if (x>11);
System.out.println("Hello"+x);
a) No output
b) Hello10
c) Compilation error
d) Hello11
• Which of the following are valid operations?
a) s3=s1*s2
b) s3 = s1-s2
c) s3= s1+s2
d) s3 = s1&s3;
• If boolean expression in the if block evaluates to false,
then which statement set will be executed?
if (booleanExpression)
{
statementSet 1
}
else
{
statementSet 2
}
statementSet 3
• a) statementset1 b) statementset2 c) ststementset3
d) statementset 2 and statementset 3
• What should be the missing line to get the output 100?
public class Example
{
public static void main(String args[])
{
int x = 0;
//__________
do
{
}
while(x++ < y);
System.out.println(x);
}
}
• a) int x=99; b) int x=100; c) int y=99; d) int y=100;
• Create a stack S of size 4, perform the following
operations and find the end result.
PUSH(S, A)
PUSH(S, B)
PUSH(S, C)
POP(S)
PUSH(S, D)
PUSH(S, E)
• a) Top = E b) Stack overflow c) Stack underflow
• d) TOP = D
• Which compound statement in a looping statement
is correct?
a) c=a+b
b) c=+b
c) c+=b
d) c=a-b
• EOL in the programming language indicates
a) End of line
b) End of language
c) Everything on line
d) End of life
• A __________ statement consists of a sequence of
two or more consecutive statements enclosed in
braces ({and}).
a) expression
b) compound
c) control
d) equation
• Complete the below given statement.
main()
printf(“\nH\re\rll\ro”);
a) hello
b) o
c) Error
d) ol
• What will be the output of the following program?
main()
{
static int i=100;
abc();
}
Void abc()
{
printf(“%d”,i);
}
• a) 100 b) 0 c) Error d) warning
• How to Pass a String to a Function?
b) void display
c) (chars[])
d) function(s)
• What is the output of the following code snippet?
#include<stdio.h>
#include<math.h>
int main()
{
int n,sum,i,temp,remainder;
printf("The Armstrong numbers in between 1 to 400 are : ");
for(i = 1; i <= 400; i++)
{
temp = i;
sum = 0;
while(temp!=0) {
remainder=temp%10;
sum=sum+pow(remainder,int(log10(n)+1));
temp=temp/10; }
if(i==sum) {
printf("\n%d", i); }
}
}
a) The Armstrong numbers in between 1 to 400 are :
1
153
370
b) The Armstrong numbers in between 1 to 400 are :
1
370
371
c) The Armstrong numbers in between 1 to 400 are :
1
153
371
d) The Armstrong numbers in between 1 to 400 are :
123456789
153
370
371
• How to define a C-string?
a) char str[]=”C++”;
b) char str=”C++” ;
c) str[]=”C++”;
d) char()= “C++”;
• How many parameters can a resize method take?
a) 2
b) 1
c) 1 or 2
d) 0
• Which header file is used to manipulate the string?
a) string
b) iostream
c) conio
d) getch
• Find the output of the following code.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string string ("computer applications&***");
cout << string.length();
return 0;
}
• a) computerapplication b) 25
• c) computer appications&***” d) error
• Find the output of the following code.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string m ("Mr.");
string f ("Mrs.");
m += " Gold ";
m += f;
m += '\n';
cout << m;
return 0;
}
• a) Mr. Gold b) Mr. Gold Mrs. c) Mr.Mrs. d) Gold
• Find the output of the following code.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Xubuntu");
cout << str(3);
return 0;
}
• a) Xub b) Xubuntu c) bun d) error
• Find the output of the following code.
#include <iostream>
#include <cstring>
using namespace std;
int main ()
{
char s1[15] = "WELCOME ";
char s2[30] = "COMPUTER APPLICATION";
char s3[30];
int len ;
strcpy( s3, s1);
strcat( s1, s2);
len = strlen(s1)
cout << len << endl;
return 0;
}
• a) 28 b) WELCOME c) COMPUTER APPLICATION
• d) WELCOME COMPUTER APPLICATION
• Which of the following options correctly declares an
array?
a) int b[10];
b) int b;
c) array[10]
d) b{10}
• What will be the output of the following program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("soft skill");
string::reverse_iterator r;
for (r = str.rbegin() ; r < str.rend(); r++ )
cout << *r;
return 0;
}
• a) skill b) lliks tfos c) lliks soft d) soft
• To read the characters from the keyboard, it calls
which of the following methods?
a) System.in.read()
b) System.out.read()
c) System.in.io()
d) System.out.io()
• In the following syntax, what is x mod 10 and y mod
10?
int x=42;
double y=42.5;
a) 2,2.5
b) 4,4.5
c) error
d) 2.5
• What is the output of the following program?
int a=1;
int b=2;
System.out.println (a>b);
a) 1
b) False
c) 0
d) True
• What is the time complexity of searching an
element in the circular linked list?
a) O(logn)
b) O(1)
c) O(nlogn)
d) O(n)
• The use of free() command
a) Add Z, X
b) Add Y, W
c) Delete 3 letters
d) Add J
e) Delete 2 letters
• a) empty queue b) only one element in the queue
d) 0
• Which library function can be used as an alternative
to scan string value from user/keyboard?
a) getstr
b) scanstr
c) gets
d) getstring
• Which of the following library functions can be used
to copy one string into another?
a) strcopy()
b) strcpy()
c) stringcopy()
d) stringcpy()
• What will be the output of the following code?
int prime = 3;
if(prime)
{
System.out.println("Prime Number");
}
else
{
System.out.println("Not a prime number");
}
• a) Prime Number b) Not a prime number
• c) No output d) Compilation error
• Which of the following methods is used to display
the message at the bottom of the browser during
the start of an applet?
a) status()
b) showStatus()
c) bottom()
d) showBottom()
• State whether the following statements are true or
false.
1. Package statement cannot be defined after import
statement in Java
2. We can have comments before the package statement
a) Both statements are true
b) Both statements are false
c) Statement 1 is true and statement 2 is false
a) Garbage value
b) Hello I am Java Program
c) Compilation error
d) No Output
• What will be the output of the following program?
switch(count)
{
case 1:
switch(target)
{
case 0:
System.out.println("Hi");
break;
case 1:
System.out.println("Java");
break;
}
break;
case 2: // ... Select the correct option
a) Nested switch case are not supported by Java
b) Syntax of nested switch is correct and no syntax error
c) Syntax of inner switch is correct but syntax of outer switch is wrong
d) Syntax of inner switch is wrong but syntax of outer switch is correct
• What type of for loop is this?
for (String s : a)
{
System.out.println(s);
}
• a) Enhanced for loop b) Normal for loop
-((A+B+C)*-(E+F)))
a) Balanced
b) Unbalanced
• The general form of "for" statement is
a) +=
b) ++
c) --
d) **
• Which looping statement is used to print
**
***
**** ?
a) while
b) for
c) dowhile
d) if
• What will be the output of the following program?
main()
{
auto volatile short p=0;
p++;
printf(“\n%d”,sizeof(p));
}
a) 2
b) Error: No such data type
c) Error: Conflicting data types
d) Error: Cannot modify an auto volatile type variable.
• What will be the output of the following program?
main()
{
void *p;
long x=65536+300;
p=&x;
printf(“\n%d..”,*(char *)p);
printf(“%d..”,*(int *)p);
printf(“%\d”,*(long *)p);
}
• a) 43..65 b) 44..65836..65836
• c) 44..300..65876 d) Error
• Which function is used to concatenate a string?
a) concat()
b) strcat()
c) concatenate()
d) stringcat()
• The operator used for dereferencing or indirection
is
a) @
b) *
c) &
d) .
• Which header file is used for manipulators?
a) <stdiomanip.h>
b) <iomanipulator.h>
c) <stdmanip.h>
d) <iomanip.h>
• Encapsulation is also referred as
a) data refining
b) data loading
c) data hiding
d) data reloading
• C++ provides a special __________ called the
constructor, which enables an object to initialize
itself when it is created.
a) member variables
b) member function
c) function
d) objects
• Find the output of the following code
#include <iostream>
using namespace std;
int main()
{
double S = 0;
float D = 0;
int x ,y;
x = (int) S;
y = (int) D;
cout << x <<' '<< y;
return 0;
}
• a) 0 0 b) 11 c) Error d) 2 2
• What is the result of the following syntax?
c) Allocates a 4 by 5 array
a) SIZE_CHAR
b) CHAR_SIZE
c) CHAR_BIT
d) SIZE_INT
• What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main()
{
char N = 120;
cout << N*7*78;
return 0;
}
• a) Error b) 840 c) H d) 65520
• In Java, the data types, byte, short, char values are
automatically promoted to
a) int
b) byte
c) bit
d) short
• In the following syntax, what is the value of b?
byte b=50;
b=b*2;
a) 100
b) 50
c) Error
d) 2
• In the following syntax, what happens to a, b, c?
byte a=40;
byte b=50;
byte c=100;
int d=a*b/c;
b) It is executed as it as
c) Error is shown
a) format()
b) string()
c) scanf()
d)get()