Está en la página 1de 18

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: Delphi Sample Programming Placement Paper Level1 (Bolded option is your answer) 1. 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() { 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 00 C 00 00 AC 40

D 00 00 CA 04

2. We want to round off x, a float, to an int value, The correct way to do is A y = (int)(x + 0.5) B y = int(x + 0.5) C y = (int)x + 0.5 D y = (int)((int)x + 0.5)

3. Can you combine the following two statements into one? char *p; p = (char*) malloc(100); A char p = B char *p = C char *p = D char *p = (char *malloc(100); (char) (char*)malloc(100); *)(malloc*)(100);
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

4. 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*)); return 0; } A memfree(int B dealloc(p); C malloc(p, 0); p); 5. 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; }
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 free(p);

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 Infinite times B 11 times

C 0 times

D 10 times

6. 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) { printf("%c %d\n", j, j); j++; } return 0; } A Infinite times B 255 times

C 256 times

D 254 times

7. What is the notation for following functions? 1. int f(int a, float b) { /* Some code */ } 2. int f(a, b) int a; float b; { /* Some code */ }
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 1. KR B 1. Pre ANSI C 1. ANSI Notation Notation C Notation 2. KR Notation 2. ANSI 2. KR Notation Notation 8. How many times the program will print "IndiaBIX" ? #include<stdio.h> int main() { printf("IndiaBIX"); main(); return 0; } A Infinite times B 32767 times C 65535 times

D 1. ANSI Notation 2. Pre ANSI Notation

D Till stack overflows

9. In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain? A "I am a B "I am a C "I am a boy\n\0" D "I am a boy" boy\r\n\0" boy\r\0" 10. Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+"); A Reading B Writing C Appending D Read and Write 11. To print out a and b given below, which of the following printf() statement will you use? #include<stdio.h>
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

float a=3.14; double b=3.14; A printf("%f B printf("%Lf %lf", a, b); %f", a, b);

C printf("%Lf %Lf", a, b);

D printf("%f %Lf", a, b);

12. 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

13. What will be the output of the C#.NET code snippet given below? int num = 1, z = 5; 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;
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

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 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. Which of the following ways to create an object of the Sample class given below will work correctly? class Sample { int i;
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

Single j; double k; public Sample (int ii, Single jj, double kk) { i = ii; j = jj; k = kk; } } A Sample s1 = new Sample(); B Sample s1 = C Sample s2 = new D Sample s3 = new Sample(10, 1.2f); new Sample(10, Sample(10); 1.2f, 2.4); 18. 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) {
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

Sample.Bix1(); } } } A Sample class B Bix1 Bix1 method method C Sample class D Bix1 method Sample class

19. 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 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 = s2 C s1 == s2 D s1.Equals(s2)

21. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { string str= "Hello World!"; Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() ); }
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

} } A0 B1 C System.Int32 D String

22. Which of the following will be the correct output for the C#.NET code snippet given below? String s1="Kicit"; Console.Write(s1.IndexOf('c') + " "); Console.Write(s1.Length); A36 B25 C35

D26

23. Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "Five Star"; String s2 = "FIVE STAR"; int c; c = s1.CompareTo(s2); Console.WriteLine(c); A0 B1

C2

D -1

24. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[] args)
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 num = 1; funcv(num); Console.Write(num + ", "); funcr(ref num); Console.Write(num + ", "); } static void funcv(int num) { num = num + 10; Console.Write(num + ", "); } static void funcr (ref int num) { num = num + 10; Console.Write(num + ", "); } } } A 1, 1, 1, 1, B 11, 1, 11, 11, C 11, 11, 11, 11, D 11, 11, 21, 11,

25. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[] args) { int[]arr = newint[]{ 1, 2, 3, 4, 5 }; fun(ref arr); }
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 void fun(ref int[] a) { for (int i = 0; i < a.Length; i++) { a[i] = a[i] * 5; Console.Write(a[ i ] + " "); } } } } A12345 B 6 7 8 9 10 C 5 10 15 20 25 D 5 25 125 625 3125

26. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[] args) { int a = 5; int s = 0, c = 0; Proc(a, ref s, ref c); Console.WriteLine(s + " " + c); } static void Proc(int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * 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

} } } A00 B 25 25 C 125 125 D 25 125

27. Which one is a valid declaration of a boolean? A boolean b1 = B boolean b2 0; = 'false'; C boolean b3 = false; D boolean b4 = Boolean.false();

28. switch(x) { default: System.out.println("Hello"); } Which two are acceptable types for x? 1.byte 2.long 3.char 4.float 5.Short 6.Long A 1 and 3 B 2 and 4 C 3 and 5 29. class Foo { class Bar{ } } class Test { public static void main (String [] args)

D 4 and 6

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

{ Foo f = new Foo(); /* Line 10: Missing statement ? */ } } which statement, inserted at line 10, creates an instance of Bar? A Foo.Bar b = B Foo.Bar b = C Bar b = new D Bar b = f.new new Foo.Bar(); f.new Bar(); f.Bar(); Bar(); 30. public class Test { public void foo() { assert false; /* Line 5 */ assert false; /* Line 6 */ } public void bar() { while(true) { assert false; /* Line 12 */ } assert false; /* Line 14 */ } } What causes compilation to fail? A Line 5 B Line 6 C Line 12 31. What will be the output of the program? public 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

D Line 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

{ public static int y; public static void foo(int x) { System.out.print("foo "); y = x; } public static int bar(int z) { System.out.print("bar "); return y = z; } public static void main(String [] args ) { int t = 0; assert t > 0 : bar(7); assert t > 1 : foo(8); /* Line 18 */ System.out.println("done "); } } A bar B bar done C foo done D Compilation fails

32. public class Test2 { public static int x; public static int foo(int y) { return y * 2; } public static void main(String [] args)
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 z = 5; assert z > 0; /* Line 11 */ assert z > 2: foo(z); /* Line 12 */ if ( z < 7 ) assert z > 4; /* Line 14 */ switch (z) { case 4: System.out.println("4 "); case 5: System.out.println("5 "); default: assert z < 10; } if ( z < 10 ) assert z > 4: z++; /* Line 22 */ System.out.println(z); } } which line is an example of an inappropriate use of assertions? A Line 11 B Line 12 C Line 14 D Line 22 33. public class Outer { public void someOuterMethod() { //Line 5 } public class Inner { }
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[] argv) { Outer ot = new Outer(); //Line 10 } } Which of the following code fragments inserted, will allow to compile? A new Inner(); B new Inner(); C new ot.Inner(); D new //At line 5 //At line 10 //At line 10 Outer.Inner(); //At line 10 34. What is the narrowest valid returnType for methodA in line 3? public class ReturnIt { returnType methodA(byte x, double y) /* Line 3 */ { return (long)x / y * 2; } } A int B byte C long D double 35. What will be the output of the program? try { int x = 0; int y = 5 / x; } catch (Exception e) {
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("Exception"); } catch (ArithmeticException ae) { System.out.println(" Arithmetic Exception"); } System.out.println("finished"); A finished B Exception C Compilation fails. D Arithmetic Exception 36. What will be the output of the program? public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (RuntimeException ex) /* Line 10 */ { System.out.print("B"); } catch (Exception ex1) { System.out.print("C"); } finally {
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.print("D"); } System.out.print("E"); } public static void badMethod() { throw new RuntimeException(); } } A BD B BCD C BDE D BCDE

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

También podría gustarte