Vous êtes sur la page 1sur 23

Infosys Test-2 Questions

1. Which of the following tests consists of dividing all possible inputs into a set of classes, here either all inputs that fall into a given class are valid or all are invalid. (C) A.Boundary Value Analysis B.Error Guessing C. Equivalence Class Partitioning D. Random Generation 2. The global variables are stored into ___________. (C) A. Stack B. Heap C. Code Segment D. Data Segment 3.Which of the following statements is/are TRUE about structures: (C) (i) A structure variable can be a member of another structure. (ii) A structure can have an array as its member variable. (iii) A structure cannot declare a member as an array of structures. (iv)Structure variable always gets passed by reference. (v) We can return a structure variable from a function.

A. (ii), (iii) and (iv) B. (i), (ii) and (v) C. (i), (ii) and (iii) D. (i), (ii) and (iii) 4. You need to decide on an optimal search algorithm to be used to search for a data which is to be stored in an alphabetically sorted order. Which method would you use? (C) A. Linear Search B.Radix Search C. Binary Search D. Quick Search

5. A programmer wants to concatenate the character ! with a variable s (it is a character array and sufficiently large) . What is the correct call to the library function strcat? (C) A)strcat(s,"!") B)strcat("!",s)

C)strcat('!' , s) D)strcat(s,'!') A. A B. C C. D D. B 6. What is the output of the following program? (A) #define SQUARE(n) n*n main(int argc, char *argv[]) { int iVar; iVar = 16/SQUARE(2); printf("iVar=%d",iVar); } A. 64 B. 16 C. 8 D. 4 7. How many instances of the variable my_value will be created during the execution of the following program? (A) int igVar=2; main(int argc, char *argv[]) { int imy_value; fnMy_function(); }

fnMy_function () { int imy_value; if (igVar ==0 ) return(); for( ; igVar -- ;) fnMy_function() ; }

A. infinite B. Cannot be determined, since the program will stop execution due to memory fault C. 4 D. 6 8. How many iterations will be there for the following "while" loop? iVar = 0; iNum = 10; while (iVar < iNum) { iVar = iVar + 2; iVar = iVar - 1; } A. 11 B. 9 C. 12 D. 10 9. Which one of the following statements about pointer is FALSE? (A) A. Pointer variables do have data types B. No memory is allocated for pointer variable C.Pointer variable is used to hold the address D. The sizes of all types of pointer variables are different 10. A process running the following code has 1KB memory allocated for the stack region. int iFactorial (int iNum) { if (iNum==0) return (1); else return (n*iFactorial(n-1)); }

The function is called iFactorial(257). Assuming that an integer takes 4 bytes on your machine and operating system,find the number of times recursion will happen before a "stack overflow" occurs. (A)

A. 256 B. 1024 C. None of these D. 257 11. Unit Test is done by (M) A. Module leader B. Analyst C. Project manager D. Programmer 12. main(int argc, char *argv[]) { /*we need to populate the character array s*/ char caArray[10]; printf("Enter a string"); scanf("%s",cArray); } Choose the correct observation based on the code above Note -You may ignore the absence of any header file inclusion and any syntax error (P) A. The code may result in syntax error while compiling B. The code is correct , but since the function scanf does not automatically checks for overflow of the buffer , it may result in runtime error .Code Segment C. The code may result in runtime error, since the second argument to printf must be &s and not s D. The code may result in linker error 13. What does the following program prints? (P) main(int argc, char *argv[]) { printf("Size =%d", sizeof('A')); }

Note -You may ignore the absence of any header file inclusion or any syntax error and assume a 32 bit environment A. Size=4 B. Size=8 C. Size=2 D. Size=1 14. Which is NOT a Pre-requisite for code Review? (P) A. The source file should contain proper documentation B. The code must be readable C.System testing should have been completed D. The code should compile and execute with zero errors and warnings 15. Consider the following code fragment to report the size of an array ... fnFunc(char a[10]) { int i=sizeof(a); printf("%d\n",i); } Assume in the machine size of char pointer = size of interger = 4 bytes and size of char = 1byte . What will the possible output of the code? Note -You may ignore the absence of any header file inclusion and any syntax error (P) A. 10 B. 4 C. 6 D. 8 16. _________is the symbol that is used to denote a private member in class diagram. A. # B. + C. * D.

17. The most common operation used in constructors A.polymorphism B. assignment C. Overriding D. addition 18. Which of the following statements are TRUE? (C) 1. Abstract modifier cannot be used with the static methods 2. Abstract class can be instantiated 3. Interface has only abstract methods while abstract class can have concrete methods A. only 1 and 2 B. All are true C. only 2 and 3 D. only 1 and 3 19. Which of the following is TRUE about how variables are passed to methods? (C) A. Arguments that are of primitive type are passed by value B. Real arguments are always passed by value, since java does not have the concept of pointers C. Real arguments are always passed by reference D. Arguments that are passed with the use of & operator are passed by reference 20. Which is NOT true about static? (C) A. static methods can be overridden in the derived class B. A static member can be accessed by using the class name C. A static method can only call other static method D. A static method can access only static variables 21. Which of the following is NOT true about Interface? (C) A. Interfaces are used when a role needs for to be defined for classes B. Interface can have concrete methods C.Interface cannot have private and protected members D. The member variables of an interface are public , static , final by default

22. Analyze the following code for any Errors: (A) abstract class AbstractDemo { void methodOne() { // some code } abstract void methodThree(); abstract void methodTwo(); } public class Child extends AbstractDemo { public void methodOne() { // some code } public void methodThree() { // some code } public static void main(String args[]) { AbstractDemo ref=new Child(); System.out.println("Created object of CheckIt"); } } A. AbstractDemo reference cannot point to the object of Child B.Compile time error C. Runs successfully but no output D. Runtime error 23. Which of them is NOT a widening conversion in type casting? (A) A. char to a long B. char to a short C. short to an int D. byte to a short 24. What would be the output of the following code:- (A) class Figure{ public void display()

{ System.out.println("Inside class Figure"); } } public class ChildFigure extends Figure{ public void display() { System.out.println("Inside child of Figure"); } public static void main(String args[]) { Figure ref = new Figure(); ChildFigure obj=(ChildFigure) ref; obj.display(); } } A. Will display - Inside class Figure B. will display Inside child of Figure C. Provide ClassCastException during run time D. Compilation error 25. Consider a banking application. There is an Account class to create an account and to perform any transaction by the customers. There is another class called Loan-Advisor class which the customers can avail any loans. Which relationship is most suitable in this scenario? (A) A.Is-A B. Uses-A C. Has-A D. All of these 26. What would be the output of the following code:- (A) public class CheckStaticBlock{ static int Number=10; static{ Number +=10;} public static void main(String args[]) { System.out.println("Number = "+ Number); }

static{ Number /=5;} } A. Will give compile time error as multiple static blocks cannot exist B. Code compiles fine and execution of code produces output x=4 C. Code compiles fine and execution of code produces output x=20 D. Code compiles fine and execution of code produces output x=10

27. Mr. Kumar was driving a car and he was enjoying the trip along with his family members. Suddenly, he heard the burst sound and car started to wobble. Immediately he applied the brake and stopped the car carefully in the roadside. He went down from the car to check what happened and he found that one of the front wheels is punctured. Now, what is the relationship between car and wheels? (A) A. Uses-A B. All of these C. Has-A D. Is-A 28. Which symbol is used to represent Composite Aggregation? (M) A. hollow B. triangle C. rectangle D. filled hollow

29. What would be the output of the following code:- (P) class Figure{ int a=50; public void display() { System.out.println("a="+a); } } public class ChildFigure extends Figure{ int a=40;

public static void main(String args[]) { Figure ref = new ChildFigure(); System.out.println("a="+ref.a); } } A.Compile time error as the child and base class cannot have variables with same name B.Will print a=50 C. Run time error D. Will print a=40

30. How many String objects are tend to be garbage collected with the execution the following Code ? (P)

public class DemoGarbage{ public static void main(String args[]) { String check=new String("World"); String one=new String("Happy"); String two="Happy"; one=check; check=null; } } A. 2 B. 3 C. 0 D. 1 31. What would be the output of the following code:- (P) abstract class Example{ void disp(){ System.out.println("disp in Example");

} public abstract void display(); } abstract class Example1 extends Example{ public void display1(){ System.out.println("display in Example1"); } } class Example2 extends Example1{ public void display(){ System.out.println("display in Example2"); } } class Demo7{ public static void main(String args[]){ Example1 obj=new Example2(); obj.display(); obj.display1(); obj.disp(); } } A) display in Example2 display in Example1 disp in Example B) display in Example1 disp in Example C) Compilation error due to invocation of obj.display1() D) Compilation error due to invocation of obj.disp() A. D B. B C. A D. C 32. What would be the output of the following code:- (P) class Addition{ private int result; void add(int numOne,int numTwo,int numThree){

result=numOne+numTwo+numThree; System.out.println("Addition of three Numbers:"+result); } void add(float a, float b){ System.out.println("float result=" + (a+b)); } void add(double a, double b){ System.out.println("double result=" + (a+b)); } }

class MethodOverloading{ public static void main(String args[]){ Addition obj=new Addition(); obj.add(10,20); obj.add(10,20,30); obj.add(2.4f, 3.5f); } } A) float result=30.0 Addition of three Numbers:60 float result=5.9 B) Addition of three Numbers:60 float result=5.9 double result=5.900000000 C) Compilation error due to invocation of a add(10,20) with no method definition D) float result=30.0 Addition of three Numbers:60 double result=5.900000000 A. B B. D C. A

D. C 33. What would be the output of the following code:- (P) package a; public class External{ int Number1; protected int Number2; public void display() { System.out.println("Number="+ Number1); } package b; import a.External; public class Internal extends External{ public static void main(String args[]) { Internal obj=new Internal(); obj. Number1=10; obj. Number2=obj. Number1*2; System.out.println(obj. Number1); } } A. Will print 0, 10 B. Compilation Error as Number1 accessed in different package C. Classes belonging to different packages cannot inherit from one another D. Will print 20 34. What would be the output of the following code:- (P) public class DemoClass{ private static int Number=10; public static void main(String args[]) { DemoClass objOne=new DemoClass(); objOne. Number ++; DemoClass objTwo=new DemoClass(); objTwo. Number ++;

DemoClass. Number ++; objTwo=new DemoClass(); objTwo. Number ++; System.out.println("X is: "+ Number); } } A. compile time error as main function is making static reference to a private variable B. Will print X is 11 C. Will print X is 14 D. Will print X is 13 35. What would be the output of the following code:- (P) class Customer{ static{ System.out.println("Customer static"); } Customer() { System.out.println("Constructor"); } } class StaticBlock { static { System.out.println("Main static"); } public static void main(String args[]){ Customer custObj1; } } A) Main static Customer static Constructor B) Main static C) Compilation error due to object not created for Customer class D) Customer static Main static Constructor

A. A B. D C. B D. C 36. What would be the output of the following code:- (P) public class DemoClass{ private static int x=10; public static void main(String args[]) { DemoClass objOne=new DemoClass(); objOne.x++; DemoClass objTwo=new DemoClass(); objTwo.x++; DemoClass.x++; objTwo=new DemoClass(); objTwo.x++; System.out.println("X is: "+x); } } A. Will print X is 14 B. Will print X is 11 C. Will print X is 13 D. compile time error as main function is making static reference to a private variable 37. What would be the output of the following code:- (P) public class OverloadingDemo{ public void functionFirst(float a, int b) { System.out.println("Inside float");} public void functionFirst(int a , float b) { System.out.println("Inside int");} public void functionFirst(double a , double b) { System.out.println("Inside double");} public static void main(String args[]) {

OverloadingDemo objOne=new OverloadingDemo(); objOne.functionFirst(10.0,20); //1 objOne.functionFirst(10.0f,20); //2 objOne.functionFirst(20,20); //3 } } A. Code will not compile because of line 4 B. Code will compile successfully C. Code will not compile because of line 3 D. Code will not compile because of line 2 38. What would the output of this Code snippet ? (P) class Figure{ public void display() { System.out.println("Inside class Figure"); } } public class ChildFigure extends Figure{ public void display() { System.out.println("Inside child of Figure"); } public static void main(String args[]) { Figure ref = new Figure(); ChildFigure obj=(ChildFigure) ref; obj.display(); } } A. will display - Inside child of Figure B. Will display Inside class Figure C. Compile time error due to base class reference assigned to subclass reference D. Provide ClassCastException during run time 39. What would be the output of the following code:- (P)

package a; public class External{ int a; protected int b; public void display() { System.out.println("a="+a); } package b; import a.External; public class Internal extends External{ public static void main(String args[]) { Internal obj=new Internal(); obj.a=10; obj.b=obj.a*2; System.out.println(obj.b);} } A. Classes belonging to different packages cannot inherit from one another B. Will print 20 C. Compile time error D. Runtime error 40. What would the output of this Code snippet ? (P) class CheckIt{ int a; private CheckIt() { a=0; } CheckIt(int val) { this(); a=val; } }

public class CheckDemo{ public static void main(String args[]) { CheckIt ref=new CheckIt(5); System.out.println("Created object of CheckIt"); } } A. Cannot use this() inside the constructor B. Run time error C. Compile time error due to private in default constructor D. Will print - Created object of CheckIt 41. In the relationship Prescription connects Doctor, patient, medicine. This is an example of A. Binary relationship B. one-to one relationship C. Ternary relationship D. Unary relationship 42. A relation schema R is in 2NF if it is in 1NF and every non-prime attribute is ___________ on every key of R (C) A. Transitive dependent B. Not dependent C. Fully functionally dependent D. Partially dependent 43. Which SELECT statement could you use if you wanted to display unique combinations of the ID_NUMBER and MANUFACTURER_ID values from the INVENTORY table? (C) A. SELECT id_number, manufacturer_id FROM inventory B. SELECT DISTINCT manufacturer_id FROM inventory C. SELECT id_number, DISTINCT manufacturer_id FROM inventory; D.SELECT DISTINCT id_number, manufacturer_id FROM inventory 44. If there are 2 backward references in an Assembly Language program , which of the following Assembler can be used? A. Three pass assembler B. Both One and Two pass assemblers

C. One pass assembler D. Two pass assembler 45. Which of the following are problems with a relation in 1NF (A) i] Insertion: A subset of a tuple cannot be inserted ii] Deletion: Valuable information may be lost in the process iii] Updation: May have to be repeated for the same piece of information iv] Selection: Obtaining the correct set of data is difficult A. Only i & iii B. Only i, ii, iii C. Only ii D. All of i, ii, iii, iv 46. In the traditional file based approach of data storage, the same data may have to be stored in more than one place. This is the issue of: (A) A. Polymorphism B. Duplication C. Abstraction D. Redundancy 47. Which of the following is NOT a translator? A. Interpreter B. Linker C. MASM D. Compiler 48. If you give grant on a view to a user: without giving grant on the underlying table (A) A. He will be able to use the view B. He will be able to use the table automatically C. None of these D. He will not be able to use the view 49. Select departmentno , count(*) from emp group by departmentno having sum(salary)>10000; (P)

A. The above query will retrieve each departmentno and total number of employees working in each departmentno from the emp table. B. Lead to error because sum(salary) is not in the column list. C. The above query will retrieve each departmentno and total number of employees working in each departmentno of those departments whose total salary > 10000 from the emp table.Complete D. The above query will retrieve each departmentno and sum of salary from the emp table. 50. EMPLOYEE table has the following data EMP_ID ------8723 4357 9823 2737 EMP_SALARY -------1230 2390 2000 2030 EMP_COMM -------200 null 100 120

What is the result of the following expression Select sum (EMP_COMM) from EMPLOYEE A. 8070 B. 7650 C. 420 D. NULL 51. Consider this statement: SELECT manufacturer_id, AVG (price) FROM inventory WHERE AVG( price) > 6.00 GROUP BY manufacturer_id ORDER BY AVG( price); Which clause will cause an error? (P) A. ORDER BY AVG( price); B. SELECT manufacturer_id, AVG (price) C. WHERE AVG( price) > 6.00 D. GROUP BY manufacturer_id

52. Select empno, ename from emp where deptno = (select deptno from dept); consider deptno is a common column in EMP and DEPT table. (P) A. Both Query will lead to error because subquery returns more than one row and Query will lead to error because = cannot be used along with subqueries are correct B. Query will lead to error because subquery returns more than one row C. Query will lead to error because = cannot be used along with subqueries D. Query will display employees belonging to any of the departments found in Dept table 53. EMPLOYEE table has the following data EMP_ID ------8723 4357 9823 2737 EMP_SALARY -------1230 2390 2000 2030 EMP_COMM -------200 null 100 120

What is the result of the following expression: Select sum (EMP_SALARY) from EMPLOYEE A. NULL B. 8070 C. 420 D. 7650

54. Consider the Employee and the Department table, Employee (Name, SSN, Address, DNO); Department( DNUM, Dname, Location); The option to be used in the Create table command to facilitate automatic deletion of employees belonging to 'Research' Department from the employee table if department number 5 tuple is deleted from Department table. (P) A. ON DELETE RESTRICT B. ON DELETE SET NULL

C. ON DELETE SET DEFAULT D. ON DELETE SET CASCADE 55. If a table contains the values 10, 20, 30, null, null for a column col1, what will the select stmt. Select count (col1) from tab produce? (P) A. 5 B. 0 C. 1 D. 3 56. Which of the following select statement is correct to find out the name, position, and salary from the employee table with the highest salary? (P) A. Select name, position, salary from employee where salary=(select max(salary) from employee) B. Select name, position, max (salary) from employee group by name, Position C. Select name, position, max (salary) from employee D. Select name, position, max (salary) from employee group by name 57. In an RDBMS, consider the query "Select eno, ename from EMP where ename= null". What will be the data fetched? (P) A. 1, null B. No rows fetched C. 1, TOM D. null, null 58. In which of the following cases would you use indexes (P) i) Tables with frequent updations, insertions ii) Tables which store huge volumes of data, primarily read-only A. Both Case i and Case ii B. Case i C. Cannot be specified D. Case ii

59. SELECT e.ename, e.employee_id, e.department_id, d.location FROM employee e. department d WHERE employee.department_id = department.department_id ORDER by e.name; This statement fails when executed. Which of the following option will correct the problem? (P) A. Remove the table name from the ORDER BY clause and use only the column name B. Use the table alias in the ORDER BY clause C. Remove the table names from the WHERE clause D. Use the table aliases instead of the table names in the WHERE clause 60. EMPLOYEE table has the following data EMP_ID EMP_SALARY EMP_COMM ------8723 4357 9823 2737 -------1230 2390 2000 2030 -------200 null 100 120

What is the result of the following expression Select sum (EMP_SALARY)+sum (EMP_COMM) from EMPLOYEE A. NULL B.7650 C. 420 D. 8070

Vous aimerez peut-être aussi