Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link]
com/group/latestoffcampusLive updates on Facebook @ [Link]
TITLE: Lehman Brothers Sample Programming Placement Paper Level1 (Bolded option is your answer) 1. void start() { A a = new A(); B b = new B(); a.s(b); b = null; /* Line 5 */ a = null; /* Line 6 */ [Link]("start completed"); /* Line 7 */ } When is the B object, created in line 3, eligible for garbage collection? A after line 5 B after C after line 7 D There is no line 6 way to be absolutely certain. 2. class HappyGarbage01 { public static void main(String args[]) { HappyGarbage01 h = new HappyGarbage01(); [Link](); /* Line 6 */ } Object methodA() { Object obj1 = new Object(); Object [] obj2 = new Object[1]; obj2[0] = obj1; obj1 = null; return obj2[0]; } }
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
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()
3. 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 = [Link](); /* Line 12 */ [Link]("newBar"); newBar = new Bar(); /* Line 14 */ [Link]("finishing"); /* Line 15 */ } } At what point is the Bar object, created on line 6, eligible for garbage collection? A after line 12 B after C after line 7, when D after line line 14 doBar() completes 15, when main() completes
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
4. 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(); } 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 5. 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?
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
A just after line B just C just after line 7 5 after line 6
D just after line 8
6. class X2 { public X2 x; public static void main(String [] args) { X2 x2 = new X2(); /* Line 6 */ X2 x3 = new X2(); /* Line 7 */ 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? A0 B1 C2 D3 7. What allows the programmer to destroy an object x? A [Link]() B C D Only the [Link]() [Link]().gc() garbage collection system can destroy an object. 8. What will be the output of the program? class PassA
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
{ public static void main(String [] args) { PassA p = new PassA(); [Link](); } void start() { long [] a1 = {3,4,5}; long [] a2 = fix(a1); [Link](a1[0] + a1[1] + a1[2] + " "); [Link](a2[0] + a2[1] + a2[2]); } long [] fix(long [] a3) { a3[1] = 7; return a3; } } A 12 15 B 15 15 C345375 D375375
9. What will be the output of the program? class Test { public static void main(String [] args) { Test p = new Test();
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
[Link](); } void start() { boolean b1 = false; boolean b2 = fix(b1); [Link](b1 + " " + b2); } boolean fix(boolean b1) { b1 = true; return b1; } } A true true B false true C true false D false false
10. What will be the output of the program? class PassS { public static void main(String [] args) { PassS p = new PassS(); [Link](); } void start() {
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
String s1 = "slip"; String s2 = fix(s1); [Link](s1 + " " + s2); } String fix(String s1) { s1 = s1 + "stream"; [Link](s1 + " "); return "stream"; } } A slip stream B C stream slip stream D slipstream slipstream slip stream stream 11. Which of the following is the correct output for the C#.NET code snippet given below? enum color { red, green, blue } color c; c = [Link]; [Link](c); A1 B -1
C red
D0
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
12. Which of the following will be the correct output for the C#.NET code snippet given below? enum color : int { red = -3, green, blue } [Link]( (int) [Link] + ", "); [Link]( (int) [Link] + ", "); [Link]( (int) [Link] ); A -3, -2, -1 B -3, 0, 1 C 0, 1, 2
D red, green, blue
13. Which of the following is the correct output for the C#.NET code snippet given below? enum color: int { red, green, blue = 5, cyan, magenta = 10, yellow } [Link]( (int) [Link] + ", " ); [Link]( (int) [Link] ); A 2, 11 B 1, 11 C 2, 6
D 1, 5
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
14. Which of the following is the correct output of the C#.NET code snippet given below? int[ , , ] a = new int[ 3, 2, 3 ]; [Link]([Link]); A 20 B4 C 18
D 10
15. Which of the following is the correct output of the C#.NET code snippet given below? int[][] a = new int[2][]; a[0] = new int[4]{6, 1, 4, 3}; a[1] = new int[3]{9, 2, 7}; [Link](a[1].GetUpperBound(0)); A2 B3 C4
D5
16. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i, j; int[ , ] arr = new int[ 2, 2 ]; for(i = 0; i < 2; ++i) { for(j = 0; j < 2; ++j) {
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
arr[i, j] = i * 17 + i * 17; [Link](arr[ i, j ] + " "); } } } } } A 0 0 34 34 B 0 0 17 17 C0000 D 17 17 0 0
17. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class Sample { int i; Single j; public void SetData(int i, Single j) { i = i; j = j; } public void Display() { [Link](i + " " + j); } } class MyProgram {
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
static void Main(string[ ] args) { Sample s1 = new Sample(); [Link](10, 5.4f); [Link](); } } } A00 B 10 5.4 C 10 5.400000 D 10 5
18. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class Sample { int i; Single j; public void SetData(int i, Single j) { this.i = i; this.j = j; } public void Display() { [Link](i + " " + j); } } class MyProgram
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
{ static void Main(string[ ] args) { Sample s1 = new Sample(); [Link](36, 5.4f); [Link](); } } } A 0 0.0 B 36 5.4 C 36 5.400000 D 36 5
19. What does the following C#.NET code snippet will print? int i = 0, j = 0; label: i++; j+=i; if (i < 10) { [Link](i +" "); goto label; } A Prints 1 to 9 B Prints 0 to 8
C Prints 2 to 8
D Prints 2 to 9
20. Which of the following is the correct output for the C#.NET program given below? int i = 20 ; for( ; ; )
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
{ [Link](i + " "); if (i >= -10) i -= 4; else break; } A 20 16 12 84 0 B 20 16 12 C 20 16 12 8 4 0 -4 -8 -12 -4 -8 840 D 16 12 8 4 0
21. What is the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { public enum color { red, green, blue }; class SampleProgram { static void Main (string[ ] args) { color c = [Link]; switch (c) { case [Link]: [Link]([Link]); break; case [Link]: [Link]([Link]); break;
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
case [Link]: [Link]([Link]); break; } } } } A red B blue C0 D1
22. 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];
23. What do the following declaration signify? char **argv; A argv is a pointer to pointer. B argv is a C argv is a function pointer to pointer. a char pointer. 24. 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;
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
D argv is a member of function pointer.
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
} A 128 B Garbage C Error value D0
25. What will be the output of the program? #include<stdio.h> int main() { 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
26. 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++);
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
return 0; } A Error BH C Hello D Hel
27. What will be the output of the program? #include<stdio.h> int get(); int main() { const int x = get(); printf("%d", x); return 0; } int get() { return 20; } A Garbage B Error value
C 20
D0
28. What will be the output of the program? #include<stdio.h> int main() { const int i=0; printf("%d\n", i++);
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
return 0; } A 10 B 11 C No output D Error: ++needs a value
29. What will be the output of the program? #include<stdio.h> int main() { const c = -11; const int d = 34; printf("%d, %d\n", c, d); return 0; } A Error B -11, 34
C 11, 34
D None of these
30. How will you print \n on the screen? A printf("\n"); B echo "\\n"; C printf('\n'); D printf("\\n");
31. If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)? #include<stdio.h> #include<math.h> int main() {
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
float a=5.375; char *p; int i; p = (char*)&a; for(i=0; i<=3; i++) printf("%02x\n", (unsigned char)p[i]); return 0; } A 40 AC 00 00 B 04 CA 00 C 00 00 AC 40 00 D 00 00 CA 04
32. The binary equivalent of 5.375 is A B 101.011 101.101110111 C 101011 D None of above
33. How many bytes are occupied by near, far and huge pointers (DOS)? A near=2 far=4 B near=4 C near=2 far=4 huge=8 D near=4 huge=4 far=8 far=4 huge=8 huge=8 34. How will you free the memory allocated by the following program? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int **p, i, j; p = (int **) malloc(MAXROW * sizeof(int*));
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
return 0; } A memfree(int p); B C malloc(p, 0); dealloc(p); D free(p);
35. How many times "IndiaBIX" is get printed? #include<stdio.h> int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("IndiaBIX"); } return 0; } A Infinite times B 11 times C 0 times
D 10 times
36. How many times the while loop will get executed if a short int is 2 byte wide? #include<stdio.h> int main() { int j=1; while(j <= 255)
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]
{ printf("%c %d\n", j, j); j++; } return 0; } A Infinite times B 255 times C 256 times D 254 times
Visit [Link] for placement papers, interview tips & job updates. Toget freeupdates tomail [Link] updates on Facebook @ [Link]