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

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: Huawei 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 */ 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 2. 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 5 B just after line C just after line D just after line 8 6 7 3. What is the numerical range of char?
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 0 to 32767

B 0 to 65535

C -256 to 255

D -32768 to 32767

4. Which of the following are Java reserved words? 1.run 2.import 3.default 4.implement A 1 and 2 B 2 and 3 C 3 and 4 5. Which is valid declaration of a float? A float f = 1F; B float f = 1.0; C float f = "1";

D 2 and 4

D float f = 1.0d;

6. Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization? A B C D java.util.SortedM java.util.TreeM java.util.TreeSe java.util.Hashta ap ap t ble 7. class Foo { class Bar{ } } class Test { public static void main (String [] args) { Foo f = new Foo(); /* Line 10: Missing statement ? */ }
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

} which statement, inserted at line 10, creates an instance of Bar? A Foo.Bar b = new Foo.Bar(); B Foo.Bar b = f.new Bar(); C Bar b = new f.Bar(); D Bar b = f.new Bar();

8. What will be the output of the program? public class Test { 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

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

9. Which will contain the body of the thread? A run(); B start(); C stop(); D main();

10. Which class or interface defines the wait(), notify(),and notifyAll() methods? A Object B Thread C Runnable D Class

11. For the code snippet given below, which of the following statements are valid? public class MyContainer<T> where T: IComparabte { // Insert code here } 1.Class MyContainer requires that it's type argument must implement IComparabte interface. 2.Type argument of class MyContainer must be IComparabte. 3.Compiler will report an error for this block of code. 4.This requirement on type argument is called as constraint. A 1 and 2 Only B 1, 2 and 3 C 1 and 4 Only D All of the Only above 12. How many enumerators will exist if four threads are simultaneously working on an ArrayList object? A1 B2 C3 D4

13. Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the capacity of the Collection on adding fifth element to it?
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

A4

B8

C 16

D 32

14. Which of the following is the correct output of the C#.NET code snippet given below? int[ , , ] a = new int[ 3, 2, 3 ]; Console.WriteLine(a.Length); A 20 B4

C 18

D 10

15. What does the following C#.NET code snippet will print? int i = 0, j = 0; label: i++; j+=i; if (i < 10) { Console.Write(i +" "); goto label; } A Prints 1 to 9 B Prints 0 to 8

C Prints 2 to 8

D Prints 2 to 9

16. What will be the output of the C#.NET code snippet given below? int i = 2, j = i; if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1))) Console.WriteLine(1); else Console.WriteLine(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

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 Compile Error D Run time Error

17. Which of the following is NOT a namespace in the .NET Framework Class Library? A System.Process B C D System.Xml System.Securit System.Threadi y ng 18. Which of the following is the correct default value of a Boolean type? A0 B1 C True D False

19. Where the default value of parameter have to be specified? A Function call B Function definition C Function prototype D Both B or C

20. Which of the following function / types of function cannot have default parameters? A Member function of class C Member D Both B and C function of structure 21. For automatic objects, constructors and destructors are called each time the objects A enter and leave scope B inherit parent C are class constructed D are destroyed B main()

22. It is a __________ error to pass arguments to a destructor. A logical B virtual C syntax D linker

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. If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor? A Preprocessor B Compiler C Linker D main() function

24. Which of the following never requires any arguments? A Member function B Friend function C Default constructor D const function

25. Constructor is executed when _____. A an object is created B an object is used C a class is declared D an object goes out of scope.

26. Which of the following also known as an instance of a class? A Friend Functions B Object C Member Functions D Member Variables

27. Which of the following is the correct order of evaluation for the below expression? z=x+y*z/4%2-1 A*/%+-= B=*/%+C/*%-+= D*%/-+= 28. Which of the following correctly shows the hierarchy of arithmetic operations in C? A/+*B*-/+ C+-/* D/*+-

29. In which order do the following gets evaluated 1. Relational 2. Arithmetic


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

3. 4.

Logical Assignment B 1234 C 4321 D 3214

A 2134

30. How will you print \n on the screen? A printf("\n"); B echo "\\n"; C printf('\n'); D printf("\\n");

31. Which of the following function is used to find the first occurrence of a given string in another string? A strchr() B strrchr() C strstr() D strnset()

32. Which of the following function is more appropriate for reading in a multi-word string? A printf(); B scanf(); C gets(); D puts();

33. Is the following statement a declaration or definition? extern int i; A Declaration B Definition C Function D Error

34. Identify which of the following are declarations 1 : extern int x; 2 : float square ( float x ) { ... } 3 : double pow(double, double); A1 B2 C 1 and 3

D3

35. How many times the while loop will get executed if a short int is 2 byte wide?
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

#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

36. Which of the following cannot be checked in a switch-case statement? A Character B Integer C Float D enum

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

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