Sei sulla pagina 1di 11

Velammal Institute of Technology

Department of Computer Science and Engineering


Infosys Campus Connect FP 5.0
PRE-TEST QUESTION PAPER
(C, C++ Programming, Database Management Systems, Python Programming)
1) Choose the correct option to fill the ?1 and ?2 so that the program prints an input string in reverse
order. Assume that the input string is terminated by a new line character.
#include<stdio.h>
void wrt_it(void.;
int main(void.
{
Printf(Enter Text);
wrt_it();
return();
}
void wrt_it(void.
{
int c;
if(?1)
wrt_it();
?2
}

a) ?1 is getchar()!=\n ?2 is getchar(c.;
b) ?1 is (c=getchar())!=\n ?2 is getchar(c.;
c) ?1 is C!=\n ?2 is putchar(c.;
d) ?1 is (c=getchar())!=\n ?2 is getchar(c.;

2) What is the output of this C code?


int main()
{
j = 10;
printf("%d\n", j++);
return 0;
}

a) 10

b) 11

c) Compile time error

c) 0
3) main()
{
static int a[20];
int x=0;
a[x]=x++;
printf(\n %d %d %d, a[0],a[1],x);
}
a) 0 1 1
b) 0 0 0
c) 0 1 0
d) 0 0 1

4) A local variable is stored in ___


a)Code segment
b)Stack segment
c)Heap segment
d) None of the above

5) What is the output of this C code?


int main()
{
int i = 7;
i = i / 4;
printf("%d\n", i);
return 0;
}
a)Run time error
b)1
c)3
d)Compile time error

6) Which of the following is a correct format for declaration of function?


a) return-type function-name(argument type);
b) return-type function-name(argument type) {}
c) return-type (argument type)function-name;
d) Both (a) and (b)

7) main()
{
float a=0.7;
if(a<0.7f)
printf(C);
else
printf(C++);
}
a) C
b) C++
c) Error
d) None of above

8) main()
{
int x=10,y=20,z=5,a
a=x<y<z;
printf(%d,a.;
}
a) 1
b) 0
c) error
d) none of above.

9) What is the output of this C code?


void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
a) Nothing
b) Compile time error
c) Junk
d) 8

10) Comment on the following expression? c = (n) ? a : b; can be rewritten as

a) if (!n)c = b; else c = a
b) if (n <= 0)c = b; else c = a;
c) if (n > 0)c = a; else c = b;
d) All of the mentioned

11) Run time polymorphism can be achieved with_____


a. Virtual Base class
b. Container class
c. Virtual function
d. Both a and c

12) When a virtual function is redefined by the derived class, it is called___________


a. Overloading
b. Overriding
c. Rewriting
d. All of these

13) If abstract class is inherited by derived class, then______________


a. Derived class should provide definition for all the pure virtual functions
b. Derived class also become abstract if fails to implement pure virtual functions
c. Objects of derived class cant be created if it fails to implement pure virtual functions
d. All of these

14) When a child class inherits traits from more than one parent class, this type of inheritance is called
_______________ inheritance.
a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple

15) If the derived class is struct, then default visibility mode is_______
a. public
b. protected
c. private
d. struct cant inherit class
16) When base class is derived in protected mode, then______________

1. public members of base class become private members of derived class


2. public members of base class become protected members of derived class
3. public members of base class become public members of derived class
4. protected members of base class become protected members of derived class
5. protected members of base class become private members of derived class
6. protected members of base class become public members of derived class

a. Only 1, 5
b. Only 1, 6
c. Only 2, 6
d. 2 , 4

17) What is difference between protected and private access specifiers in inheritance?
a. private member is not inheritable and not accessible in derived class
b. protected member is inheritable and also accessible in derived class
c. Both are inheritable but private is accessible in the derived class
d. Both are inheritable but protected is not accessible in the derived class

18) Which of the following perfect set of operators cant be overloaded in CPP ?
a. +=, ?, :: , >>
b. >>, <<, ?, *, sizeof()
c. :: , . , .* , ?:
d. :: , ->, * , new, delete

19) Members of the class can be declared with auto, extern or register storage classes.
a. True
b. False

20) Inline functions may not work ______


1. If function contain static variables
2. If function contain global and register variables
3. If function returning value consists looping construct(i.e. for, while)
4. If inline functions are recursive
5. If function contains const value

a. Only 1,4,5
b. Only 2,3,5
c. Only 1,3,4
d. All of these

21) Important advantage of using new and delete operators in C++ is


a)Allocation of memory
b)Frees the memory previously allocated
c)Allocation of memory and frees the memory previously allocated
d)Initialization of memory easily

22) Which of the following statements is correct?

a.Base class pointer cannot point to derived class.


b.Derived class pointer cannot point to base class.
c.Pointer to derived class cannot be created.
d.Pointer to base class cannot be created.

23) Which of the following is correct about the statements given below?
I.All operators can be overloaded in C++.
II.We can change the basic meaning of an operator in C++.

a.Only I is true.
b.Both I and II are false.
c.Only II is true.
d. Both I and II are true.

24) Which statement gets affected when i++ is changed to ++i?

a) i = 20; i++;
b) for (i = 0; i<20; i++) { }
c) a = i++;
d) while (i++ = 20) cout << i;

25) Regarding following statement which of the statements is true?

const int pathwidth=100;

a)Declares a variable pathwidth with 100 as its initial value


b)Declares a construction pathwidth with 100 as its initial value
c)Declares a constant pathwidth whose value will be 100
d)Constructs an integer type variable with pathwidth as identifier and 100 as value
26) Observe following function declaration and choose the best answer:

int divide ( int a, int b = 2 )

a) Variable b is of integer type and will always have value 2


b) Variable a and b are of int type and the initial value of both variables is 2
c) Variable b is international scope and will have value 2
d) Variable b will have value 2 if not specified when calling function

27) Consider the statements a = 13 ; c = a<< 3 ; (a and c are integers). The result assigned to the integer c is

a) 104
b) 114
c) 140
d) 14

28) The statement int num[2][3]={ {1,2}, {3,4}, {5, 6} };

a)assigns a value 2 to num[1][2]


b)assigns a value 4 to num[1][2]
c)gives an error message
d)assigns a value 3 to num[1][2]

29) Which of the following best defines the syntax for template function ?

a) template return_type Function_Name(Parameters)


b) template return_type Function_Name(Parameters)
c) both a and b
d) None of these

30) In a program, If there exists a function template with two parameters and normal function say void
add(int , int), so add(3,4) will_____________________

a. Invoke function template body as it is generic one


b. Invokes normal function as it exactly matches with its prototype
c. Not be called and Compiler issues warning
d. Not be called and Compiler issues ambiguity in calling add()

31) GRANT and REVOKE statements belong to

a.DQL Language
b.DDL Language
c.DCL Language
d.DML Language

32) COMMIT and ROLLBACK statements belong to

a.TCL Language
b.DDL Language
c.DCL Language
d.DML Language

33) Attribute is also known as?

a.Tuple
b.Entity
c.Row
d.Column

34)Which key is used to make relations between two tables?

a.Foreign
b.Primary
c.Candidate
d.Composite

35) Which is the correct SELECT statement to display all records with all columns of a table?

a.SELECT * FROM table_name


b.SELECT ALL COLS FROM table_name
c.SELECT FROM table_name
d.None of these

36) Which is the correct syntax for BETWEEN operator?

a.WHERE column_name BETWEEN (value1 AND value2)


b.WHERE column_name BETWEEN value1 AND value2
c.WHERE column_name BETWEEN (value1, value2)
d.WHERE BETWEEN column_name value1 AND value2

37) Which is the correct syntax for INSERT INTO statement without specifying column names?

a.INSERT INTO table_name VALUES( value1, value2, ...)


b.INSERT INTO VALUES( value1, value2, ...) table_name
c.INSERT INTO VALUES( value1, value2, ...) IN table_name
d.INSERT * INTO table_name VALUES( value1, value2, ...)

38) Which is the correct syntax for DROP DATABASE statement?

a.DROP database_name
b.DROP database_name DATABASE
c.DROP DATABASE * database_name
d.DROP DATABASE database_name

39) Which is a join condition contains an equality operator

a. Equijoins
b. Cartesian
c. Both and b
d. None of the mentioned

40) The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T.
CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T ;

a.Equi-join
b.Natural join
c.Outer join
d.Cartesian join

41) Which of the following statements are the same?


(A) x -= x + 4
(B) x = x + 4 - x
(C) x = x - (x + 4)

a.(A) and (B) are the same


b.(A) and (C) are the same
c.(B) and (C) are the same
d.(A), (B), and (C) are the same

42) What is x after the following statements?


x=1
x *= x + 1

a.x is 1
b.x is 2
c.x is 3
d.x is 4

43) Analyze the following code fragments that assign a boolean value to the variable even.
Code 1:
if number % 2 == 0:
even = True
else:
even = False
Code 2:
even = True if number % 2 == 0 else False
Code 3:
even = number % 2 == 0

a.Code 2 has a syntax error, because you cannot have True and False literals in the conditional expression.
b.Code 3 has a syntax error, because you attempt to assign number to even.
c.All three are correct, but Code 1 is preferred.
d.All three are correct, but Code 3 is preferred.

44) What is the output of the following code?


x=0
if x < 4:
x=x+1
print("x is", x)

a.x is 0
b.x is 1
c.x is 2
d.x is 4

45) What is y after the following statement is executed?


x=0
y = 10 if x > 0 else -10

a. -10
b. 0
c.10
d. 20
e.Illegal expression

46) What will be displayed by the following code?


isCorrect = False
print("Correct" if isCorrect else "Incorrect")

a.Correct
b.Incorrect
c.nothing
d.Correct Incorrect

47) Given a string s = "Welcome", which of the following code is incorrect?

a.print(s[0])
b.print(s.lower())
c.s[1] = 'r'
d.print(s.strip())

48) What is "Good".replace("o", "e")?

a.God
b.Good
c.Geed
d.Ged
e.Good

49) A variable defined outside a function is referred to as __________.

a. a global variable
b. a function variable
c. a block variable
d. a local variable

50) Suppose t = (1, 2, 4, 3, 8, 9), [t[i] for i in range(0, len(t), 2)] is _________.

a.[2, 3, 9]
b.[1, 2, 4, 3, 8, 9]
c.[1, 4, 8]
d.(1, 4, 8)
e.(2, 3, 9)

Potrebbero piacerti anche