Created
August 4, 2017 18:23
-
-
Save sudikrt/60df2cec0c53b100d4375123d7ddad6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1)Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
char s[ ]="man"; | |
int i; | |
for(i=0;s[ i ];i++) | |
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); | |
} | |
mmmm | |
aaaa | |
nnnn | |
aaa | |
nnnn | |
mmmm | |
mmmm | |
aaaa | |
nnnn mmmm | |
nnn | |
aaa | |
mmm | |
ans: 1 | |
2) Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
static int var = 5; | |
printf("%d ",var--); | |
if(var) | |
main(); | |
} | |
5 4 3 2 1 | |
5 5 5 5 5 | |
Error | |
4 3 2 1 0 | |
Ans: 1 | |
3) Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
int c[ ]={2.8,3.4,4,6.7,5}; | |
int j,*p=c,*q=c; | |
for(j=0;j<5;j++) | |
{ | |
printf(" %d ",*c); | |
++q; | |
} | |
for(j=0;j<5;j++) | |
{ | |
printf(" %d ",*p); | |
++p; | |
} | |
} | |
2 2 2 2 2 2 3 4 6 5 | |
2 2 2 2 2 3 4 2 6 5 | |
2 2 2 2 2 4 3 2 6 5 | |
2 2 2 2 2 2 2 2 2 2 | |
Ans: 1 | |
4) Give the Output | |
#include<stdio.h> | |
#define clrscr() 100 | |
main() | |
{ | |
clrscr(); | |
printf("%d\n",clrscr()); | |
} | |
Ans: 100 | |
5) Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
int i=1,j=2; | |
switch(i) | |
{ | |
case 1: printf("GOOD"); | |
break; | |
case j: printf("BAD"); | |
break; | |
} | |
} | |
GOOD | |
BAD | |
Compiler Error | |
Runtime error | |
Ans: 3 | |
6) Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
show(); | |
} | |
void show() | |
{ | |
printf("I'm the greatest"); | |
} | |
Compilation error | |
Runtime Error | |
I’m The greatest | |
Ans: 3 | |
7) Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
main(); | |
} | |
Runtime error | |
Compile time error | |
Terminated abruptly | |
Ans:1 | |
8) Give the Output | |
#include<stdio.h> | |
main() | |
{ | |
char not; | |
not=!2; | |
printf("%d",not); | |
} | |
Ans: 0 | |
9) main() | |
{ | |
char *str1="abcd"; | |
char str2[]="abcd"; | |
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); | |
} | |
Answer: | |
4 5 5 | |
2 5 4 | |
2 4 4 | |
4 4 4 | |
Ans:1 | |
10) Give the Output | |
#include <stdio.h> | |
int one_d[]={1,2,3}; | |
main() | |
{ | |
int *ptr; | |
ptr=one_d; | |
ptr+=3; | |
printf("%d",*ptr); | |
} | |
garbage value | |
Core Dump | |
Compile time error | |
3 | |
Ans: 1 | |
11) Give the Output | |
#include <stdio.h> | |
main(){ | |
unsigned int i; | |
for(i=1;i>-2;i--) | |
printf("c aptitude"); | |
} | |
Core dump | |
Compile time Error | |
Condition False in for loop | |
c aptitude c aptitude c aptitude | |
ans: 3 | |
12) | |
main() | |
{ | |
int i=-1; | |
-i; | |
printf("i = %d, -i = %d \n",i,-i); | |
} | |
i = -1, -i = 1 | |
i = 1 , -i = -1 | |
i = 1, -i = 1 | |
Compile time error | |
Ans: 1 | |
13) The classes that extend Throwable class except RuntimeException and Error are known as? | |
A) Checked Exception | |
B) Unchecked Exception | |
C) Error | |
D) None of the above | |
ANSWER: A) Checked Exception | |
14) These exceptions are seen in | |
NullPointerException, | |
ArrayIndexOutOfBoundsException, | |
ArithmeticException, | |
NumberFormatException ? | |
A) Checked exception | |
B) Unchecked exception | |
C) Checked and Unchecked | |
D) User defined exception | |
ANSWER: B) Unchecked exception | |
15)For a class defined inside a method, what rule governs access to the variables of the enclosing method? | |
1)The class can access any variable | |
2)The class can only access static variables | |
3)The class can only access transient variables | |
4)The class can only access final variables | |
a) 1 and 4 | |
b) 1 | |
c) 4 | |
d) 3 and 2 | |
Answer : c. | |
16. Which of the following is the correct syntax for suggesting that the JVM performs garbage collection. | |
a)System.free(); | |
b)System.setGarbageCollection(); | |
c) System.out.gc(); | |
d) System.gc(); | |
Answer: d | |
17)Which of the following statements are true? | |
a) At the root of the collection hierarchy is a class called Collection | |
b) The collection interface contains a method called enumerator | |
c) The interator method returns an instance of the Vector class | |
d) The Set interface is designed for unique elements | |
Answer: d)The Set interface is designed for unique elements | |
18) What will be output by the following line of code? System.out.println(010|4); | |
a)14 | |
b)0 | |
c)6 | |
d)12 | |
Answer : d) 12 | |
19)Static variable in a class is initialized when | |
a. every object of the class is created | |
b. last object of the class is created | |
c. first object of the class is created | |
d. No need to initialize static variable | |
c. first object of the class is created | |
20. Which of the following are true about static member function? | |
1. They can access non-static data members | |
2. They can call only other static member functions | |
3. They can access global functions and data | |
4. They can have this pointer | |
5. They cannot be declared as const or volatile | |
a. Only 2 | |
b. Only 2,5 | |
c. Only 2,3,4,5 | |
d. Only 2 , 3 , 5 | |
e 1,2,3,4,5 | |
Answer: d. Only 2 , 3 , 5 | |
21.Which of the following are member dereferencing operators in CPP? | |
1. * | |
2. :: | |
3. ->* | |
4. ::* | |
5. -> | |
a. Only 1, 3 4 | |
b. Only 1 and 5 | |
c. Only 3 and 4 | |
d. Only 3,4,5 | |
ANSWER: a. Only 1, 3 4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment