Sie sind auf Seite 1von 14

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.

com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

SoftSol Programming Latest Sample Placement Paper "Correct" Answers Highlighted In Bold
1. int zap (int n) { if (n<=1)then zap=1; else zap=zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap. A) 9 B) 8 C) 12 2. int i,j=1; for(i=0;i<10;i++); { j=j+1; } printf("%d %d", i, j); A) 11 10 B) 10 11

D) 15

C) 11 11

D) 10 12

3. What will be the output of the program? #include<stdio.h> int main() { static int a[2][2] = {1, 2, 3, 4}; int i, j; static int *p[] = {(int*)a, (int*)a+1, (int*)a+2}; for(i=0; i<2; i++) { for(j=0; j<2; j++) { printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i), *(*(i+p)+j), *(*(p+j)+i));
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

} } return 0; } A) 1, 1, 1, 1 B) 1, 2, 1, 2 2, 2, 2, 2 2, 3, 2, 3 2, 2, 2, 2 3, 4, 3, 4 3, 3, 3, 3 4, 2, 4, 2 4. static char *i; i=malloc(sizeof(char)); find the error; A)void B) malloc returns void 5. Find output . Int *ptr=&const; A)const B)*ptr C) 1, 2, 3, 4 2, 3, 4, 1 3, 4, 1, 2 4, 1, 2, 3 D) 1, 1, 1, 1 2, 3, 2, 3 3, 2, 3, 2 4, 4, 4, 4

C)malloc

D)malloc returns null

C) error

D)no output

6. What will be the output of the program? class conditional { public static void main(String args[]) { int i = 20; int j = 55; int z = 0; z = i < j ? i : j; // ternary operator System.out.println("The value assigned is " + z); } } A) The value B) The value C) The value assigned is 20 assigned is 55 assigned is 0

D) The value assigned is 200

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

7. Find output .. Function(i=10); A)10 B) error

C) const

D) no output

8. What is the output of the following program? public class Question { public static void main(String args[]) { String s1 = "abc"; String s2 = "def"; String s3 = s1.concat(s2.toUpperCase( ) ); System.out.println(s1+s2+s3); } } A) abcabcDEFDEF B) abcdefabcDEF C) abcdefabcdef D) None 9. sum(int x) {int t; if(x<=1) return (1); t=sum(x-3)+sum(x-1); return (t); } If 6 is passed to the function, what is the value returned to the calling function? A)6 B) 9 C)1 D)0 10. What is the result of executing the following code, using the parameters 4 and 0: public void divide(int a, int b) { try { int c = a / b; } catch (Exception e) { System.out.print("Exception ");
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

} finally { System.out.println("Finally"); } A) Prints out: B) Prints out: Exception Finally 11. What is int (*ptr) [] ()? Main() {int a[]={0,2,4,6,8}; int *ptr; ptr=a; printf(%d, *((char *) ptr+4)); } Find output? A) 6 B) 2

C) Prints out: Exception Finally

D) No output

C) 4

D) 8

12. What will be the output of the program? #include <stdio.h> #include<string.h> main() { char *s1 = "alpha", *s2 = "alpha"; if(!strcmp(s1,s2)) printf("yes\n"); } A) yes B)alpha C)s1

D)s2

13. Which takes the same memory space regardless of the type of operating system? Char* char int float main() { int I=3; while(I--) {int I=100;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

I--; Printf(%d, I); } } Find output. 99 98 97 error ANS= 99 99 99 A) 99 99 99 B) 100 99 98

C) 99 98 97

D) 98 97 99

14. What will be the output of the program? #include <stdio.h> #define MAXI 100 main(){ int done,i,x=6; done=i=0; for(i = 0; (i< MAXI) && (x/=2)>1; i++) done++; printf("%d %d\n",i,done); } A)6 B)1 0 0 C) 1 1 15. What will be the output of the program? main() {char ch; for(ch=0;ch<=255;ch++) printf(%c, ch); } A)255 B) infinite loop C)ch 16. What will be the output of the program? #include <stdio.h> main() { char str[] = "Taj is 2 miles away";

D)2 1

D)Error

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

int i; for(i=0;i<19;++i) if(isalpha(str[i]))printf("%c",toupper(str[i])); } A) TAJ IS MILES B) AWAY TAJ IS C) TAJ MILES AWAY MILES AWAY IS 17. What will be the output of the program? #include <stdio.h> int myfunc(char *str) { char *ptr =str; while(*ptr++); return ptr-str-1; } main() { printf("length is %d", myfunc("DESIS")); } A)length is 0 B)length is 4 C) length is 5 18. What will be the output of the program? #include <stdio.h> main(){ char *p="abc"; char *q="abc123"; while(*p==*q) { printf("%c %c",*p,*q); p++;q++; }} A) a bc c ab B) a ab bc c C) ab bc c a D) TAJ IS miles AWAY

D)length is 6

D) a ab c bc

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

19. What will be the output of the program? #include <stdio.h> struct _tag { int i; union { int a; int b; }c; } a; main() { a.c.a=10; printf("test %d\n",a.c.b); } A)test 0 B) test 10 C)a 20. What will be the output of the program? #include <stdio.h> #include<string.h> main() { char strp[] = "Never ever say no"; char *chp, c='e'; int i,j; chp = strrchr(strp, c); i = chp-strp; for(j=0;j<=i;j++)printf("%c",strp[j]); } A) Never eve B) Never ev C) Never ever

D)b

D)Error

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

21. What will be the output of the program? #include <stdio.h> main() { int a=10,b; b=a>=5?100:200; printf("%d\n",b); } A) 50 B) 100 C)200 22. What will be the output of the program? #include <stdio.h> main() { int i = 10; printf(" %d %d %d \n", ++i, i++, ++i); } A) 11 11 13 B) 11 13 13 C) 13 13 11 23. What will be the output of the program? #include <stdio.h> main() { int a; a = (1,45,012); printf("%d", a); } A)100 B)45 C) 10

D)10

D) 13 11 13

D) 102

24. What will be the output of the program? #include <stdio.h>


Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

#include<string.h> main() { char str[] ="DESIS India pvt. ltd."; const char *str1= str; strcpy(str1,"DESHAW"); printf("str is %s",str); } A) str is B) is str C) DESHAW DESHAW DESHAW str is 25. What will be the output of the program? #include <stdio.h> main() { int i = 1; switch(i) { printf("\nHello, "); case 1: printf("One, "); i++; break; case 2: printf("Two"); break; } } A) One, B)Two C)Hello 26. What will be the output of the program? #include <stdio.h> main() { int a[3] = {1,2,3}; int i= 2;

D) str DESHAW

D)No output

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

printf("\n %d %d\n", a[i], i[a]); } A)1 2 B)3 2 C) 3 3 D)3 1 27. What will be the output of the program? #include <stdio.h> #define scanf "%s DE Shaw" main() { printf(scanf,scanf); } A) DE %s Shaw B) %s DE Shaw C) %s Shaw DE DE Shaw DE Shaw Shaw DE 28. What will be the output of the program? #include <stdio.h> main() { int x; x = printf("%d\n",x=printf("%d\n",100)); printf("%d\n",x); } A) 100 B) 2 C) 4 4 4 2 2 100 100 29. What will be the output of the program? #include <stdio.h> fun() { printf("Yes\n"); } #define fun() printf("No\n")

D) %s DE Shaw Shaw DE

D)100

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

main() { fun(); (fun)(); } A) No Yes

B) Yes Yes

C) Yes No

D) No No

30. What will be the output of the program? #include <stdio.h> main() { int x = 10,y=2,z; z=x/*y+y*/+y; printf("%d\n",z); } A)11 B)10 C) 12 31. What will be the output of the program? #include <stdio.h> #define DESHAWCURRENTDEBUGLEVEL 1 void main(void) { int i = 10 ; int j = 15 ; #ifdef DESHAWCURRENTDEBUGLEVEL printf("%d\n",i); #else printf("%d\n",j); #endif } A) 10 B)1 C)100

D)2

D)15

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

32. What will be the output of the program? #include <stdio.h> main() { int a[] = {0,1,2,3,4}; int *p[] = {a,a+1,a+2,a+3,a+4}; int **pp = p; printf("%d, %d, %d ", *pp-a, pp-p, **pp); pp++; pp++;;++pp;*++pp; printf("%d, %d, %d ", pp-p, *pp-a, **pp); } A)4, 0, 0, 4, 4, 4 B)0, 0, 0, 0, 4, 4 C) 0, 0, 0 4, 4, 4 33. What will be the output of the program? #include <stdio.h> #include<stdlib.h> #include<ctype.h> main() { int *p, *c, i; i = 5; p = malloc(sizeof(i)); printf("\n%d",*p); *p = 10; printf("\n%d %d",i,*p); c = calloc(2,i); printf("\n%d\n",*c); } A) 0 B) 5 10 C) 5 10 5 10 0 1 0 0 0

D)0, 1, 2, 3, 4, 1

D) 0 10 0

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

34. What will be the output of the program? #include <stdio.h> main() { char *pk; const char* p; const char c = 'a'; char c1='b'; p=&c1; pk = &c; printf("%c %c",*pk,*p); } A)b a B) a b C)pk a 35. What will be the output of the program? #include <stdio.h> main() { int i=4; if (i>5) printf("Hi"); else f(i); } f(int j) { if (j>=4) f(j-1); else if(j==0)return; printf("Hi"); return; } A) HiHi B)Hi C)iH

D)a a b

D)iHiH

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus

36. What will be the output of the program? #include <stdio.h> main() { int a = 10, b = 5,c = 3,d = 3; if ((a<b) && (c = d++)) printf(" %d %d %d %d ", a, b, c, d); else printf(" %d %d %d %d ", a, b, c, d); } A) 5 10 3 3 B) 10 3 3 5 C) 10 5 3 3

D) 3 3 10 5

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. To get free updates to mail http://groups.google.com/group/latestoffcampus/subscribe Live updates on Facebook @ www.facebook.com/LatestOffCampus