Вы находитесь на странице: 1из 20

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.

com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

TITLE: GlobalLogic Sample Programming Placement Paper Level1 (Bolded option is your answer) 1. Declare the following statement? "An array of three pointers to chars". A char *ptr[3](); B char *ptr[3]; C char (*ptr[3])(); D char **ptr[3];

2. Declare the following statement? "A pointer to a function which receives nothing and returns nothing". A void *(ptr)*int; B void *(*ptr)() C void *(*ptr)(*) D void (*ptr)()

3. What will be the output of the program? #include<stdio.h> int main() { int y=128; const int x=y; printf("%d\n", x); return 0; } A 128 B Garbage value C Error 4. What will be the output of the program? #include<stdio.h> int main() {
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

D0

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

const int x=5; const int *ptrx; ptrx = &x; *ptrx = 10; printf("%d\n", x); return 0; } A5 B 10 C Error D Garbage value

5. What will be the output of the program? #include<stdio.h> int main() { const char *s = ""; char str[] = "Hello"; s = str; while(*s) printf("%c", *s++); return 0; } A Error BH C Hello D Hel

6. What will be the output of the program? #include<stdio.h> int get();


Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

int main() { const int x = get(); printf("%d", x); return 0; } int get() { return 20; } A 20 B Garbage value C Error 7. What will be the output of the program? #include<stdio.h> #include<stdarg.h> void fun(char *msg, ...); int main() { fun("IndiaBIX", 1, 4, 7, 11, 0); return 0; } void fun(char *msg, ...) { va_list ptr; int num; va_start(ptr, msg); num = va_arg(ptr, int); num = va_arg(ptr, int);

D0

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

printf("%d", num); } A IndiaBIX 1 7 11 0 B1 C4 D7

8. What will be the output of the program? #include<stdio.h> #include<stdarg.h> void dumplist(int, ...); int main() { dumplist(2, 4, 8); dumplist(3, 6, 9, 7); return 0; } void dumplist(int n, ...) { va_list p; int i; va_start(p, n); while(n-->0) { i = va_arg(p, int); printf("%d", i); } va_end(p); printf("\n"); }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A24 36

B248 3, 6, 9, 7

C48 697

D111 1111

9. What will be the output of the program? #include<stdio.h> #include<stdarg.h> void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys", "Cats", "Dogs"); fun2(2, 12, 13, 14); return 0; } void fun1(int num, ...) { char *str; va_list ptr; va_start(ptr, num); str = va_arg(ptr, char *); printf("%s ", str); } void fun2(int num, ...) { va_list ptr; va_start(ptr, num); num = va_arg(ptr, int); printf("%d", num); }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A Dogs 12

B Cats 14

C Boys 13

D Apple 12

10. In the following code, the P2 is Integer Pointer or Integer? typedef int *ptr; ptr p1, p2; A Integer B Integer pointer C Error in declaration D None of above

11. What will be the output of the C#.NET code snippet given below? byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 & b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp); A 163 92 B 92 163

C 192 63

D01

12. Which of the following statements is correct about the C#.NET code snippet given below? int d; d = Convert.ToInt32( !(30 < 20) ); A A value 0 will B A value 1 will C A value -1 will D The code be assigned to be assigned to be assigned to reports an error. d. d. d. 13. What will be the output of the C#.NET code snippet given below? int num = 1, z = 5;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

if (!(num <= 0)) Console.WriteLine( ++num + z++ + " " + ++z ); else Console.WriteLine( --num + z-- + " " + --z ); A56 B65 C66

D77

14. What will be the output of the C#.NET code snippet given below? byte b1 = 0xAB; byte b2 = 0x99; byte temp; temp = (byte)~b2; Console.Write(temp + " "); temp = (byte)(b1 << b2); Console.Write (temp + " "); temp = (byte) (b2 >> 2); Console.WriteLine(temp); A 102 1 38 B 108 0 32

C 102 0 38

D101

15. What will be the output of the C#.NET code snippet given below? int i, j = 1, k; for (i = 0; i < 5; i++) { k = j++ + ++j; Console.Write(k + " "); } A 8 4 16 12 20 B 4 8 12 16 20

C 4 8 16 32 64

D 2 4 6 8 10

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

16. What will be the output of the C#.NET code snippet given below? int a = 10, b = 20, c = 30; int res = a < b ? a < c ? c : a : b; Console.WriteLine(res); A 10 B 20

C 30

D Error

17. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { static Sample() { Console.Write("Sample class "); } public static void Bix1() { Console.Write("Bix1 method "); } } class MyProgram { static void Main(string[ ] args) { Sample.Bix1(); } } }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A Sample class Bix1 method

B Bix1 method

C Sample class

D Bix1 method Sample class

18. Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2); A ARE B CRE C CR

D REA

19. Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "Nagpur"; String s2; s2 = s1.Insert(6, "Mumbai"); Console.WriteLine(s2); A B Mumbai NagpurMumbai

C Nagpur

D NagpuMumbair

20. If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references? A s1 is s2 B s1.Equals(s2) C s1 = s2 D s1 == s2

21. void start() { A a = new A(); B b = new B(); a.s(b); b = null; /* Line 5 */
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

a = null; /* Line 6 */ System.out.println("start completed"); /* Line 7 */ } When is the B object, created in line 3, eligible for garbage collection? A after line 5 B after line 6 C after line 7 D There is no way to be absolutely certain. 22. class HappyGarbage01 { public static void main(String args[]) { HappyGarbage01 h = new HappyGarbage01(); h.methodA(); /* Line 6 */ } Object methodA() { Object obj1 = new Object(); Object [] obj2 = new Object[1]; obj2[0] = obj1; obj1 = null; return obj2[0]; } } Where will be the most chance of the garbage collector being invoked? A After line 9 B After line 10 C After line 11 D Garbage collector never invoked in methodA()

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

23. class Bar { } class Test { Bar doBar() { Bar b = new Bar(); /* Line 6 */ return b; /* Line 7 */ } public static void main (String args[]) { Test t = new Test(); /* Line 11 */ Bar newBar = t.doBar(); /* Line 12 */ System.out.println("newBar"); newBar = new Bar(); /* Line 14 */ System.out.println("finishing"); /* Line 15 */ } } At what point is the Bar object, created on line 6, eligible for garbage collection? A after line 12 B after line 14 C after line 7, D after line 15, when doBar() when main() completes completes 24. public class X { public static void main(String [] args) { X x = new X(); X x2 = m1(x); /* Line 6 */ X x4 = new X(); x2 = x4; /* Line 8 */ doComplexStuff();
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

} static X m1(X mx) { mx = new X(); return mx; } } After line 8 runs. how many objects are eligible for garbage collection? A0 B1 C2 D3 25. public Object m() { Object o = new Float(3.14F); Object [] oa = new Object[l]; oa[0] = o; /* Line 5 */ o = null; /* Line 6 */ oa[0] = null; /* Line 7 */ return o; /* Line 8 */ } When is the Float object, created in line 3, eligible for garbage collection? A just after line B just after line C just after line D just after line 5 6 7 8 26. class X2 { public X2 x; public static void main(String [] args) { X2 x2 = new X2(); /* Line 6 */ X2 x3 = new X2(); /* Line 7 */
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

x2.x = x3; x3.x = x2; x2 = new X2(); x3 = x2; /* Line 11 */ doComplexStuff(); } } after line 11 runs, how many objects are eligible for garbage collection? A2 B1 C0 D3 27. What will be the output of the program? class PassA { public static void main(String [] args) { PassA p = new PassA(); p.start(); } void start() { long [] a1 = {3,4,5}; long [] a2 = fix(a1); System.out.print(a1[0] + a1[1] + a1[2] + " "); System.out.println(a2[0] + a2[1] + a2[2]); } long [] fix(long [] a3) {
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

a3[1] = 7; return a3; } } A 12 15 B 15 15 C345375 D375375

28. What will be the output of the program? class Test { public static void main(String [] args) { Test p = new Test(); p.start(); } void start() { boolean b1 = false; boolean b2 = fix(b1); System.out.println(b1 + " " + b2); } boolean fix(boolean b1) { b1 = true; return b1; } }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A false true

B true true

C true false

D false false

29. What will be the output of the program? class PassS { public static void main(String [] args) { PassS p = new PassS(); p.start(); } void start() { String s1 = "slip"; String s2 = fix(s1); System.out.println(s1 + " " + s2); } String fix(String s1) { s1 = s1 + "stream"; System.out.print(s1 + " "); return "stream"; } } A slip stream B slipstream stream C stream slip stream D slipstream slip stream

30. What will be the output of the program?


Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

class Equals { public static void main(String [] args) { int x = 100; double y = 100.1; boolean b = (x = y); /* Line 7 */ System.out.println(b); } } A true B false C Compilation fails 31. What will be the output of the program?

D An exception is thrown at runtime

class Test { public static void main(String [] args) { int x=20; String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge"; System.out.println(sup); } } A small B tiny C huge D Compilation fails 32. What will be the output of the program? class Test {
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

public static void main(String [] args) { int x= 0; int y= 0; for (int z = 0; z < 5; z++) { if (( ++x > 2 ) && (++y > 2)) { x++; } } System.out.println(x + " " + y); } } A52 B53 C63 D64

33. What will be the output of the program? class Test { public static void main(String [] args) { int x= 0; int y= 0; for (int z = 0; z < 5; z++) { if (( ++x > 2 ) || (++y > 2)) { x++; }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

} System.out.println(x + " " + y); } } A53 B82 C83 D85

34. What will be the output of the program? class Bitwise { public static void main(String [] args) { int x = 11 & 9; int y = x ^ 3; System.out.println( y | 12 ); } } A0 B7 C8 35. What will be the output of the program? class SSBool { public static void main(String [] args) { boolean b1 = true; boolean b2 = false; boolean b3 = true; if ( b1 & b2 | b2 & b3 | b2 ) /* Line 8 */ System.out.print("ok ");
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

D 14

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

if ( b1 & b2 | b2 & b3 | b2 | b1 ) /*Line 10*/ System.out.println("dokey"); } } A ok B dokey C ok dokey D No output is produced

36. What will be the output of the program? class SC2 { public static void main(String [] args) { SC2 s = new SC2(); s.start(); } void start() { int a = 3; int b = 4; System.out.print(" " + 7 + 2 + " "); System.out.print(a + b); System.out.print(" " + a + b + " "); System.out.print(foo() + a + b + " "); System.out.println(a + b + foo()); } String foo() { return "foo";
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

} } A 9 7 7 foo 7 7foo B 72 34 34 foo34 34foo C 9 7 7 foo34 34foo D 72 7 34 foo34 7foo

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Вам также может понравиться