0% found this document useful (0 votes)
37 views17 pages

Answer of Coding Exam 01

The document provides information about an online coding test for students in various branches for year 2nd, 3rd or 4th. It contains 40 multiple choice questions related to computer programming codes in languages like C, C++, Python and Java. The questions cover topics like data types, operators, control structures, functions, classes, inheritance, polymorphism, exceptions, arrays and strings.

Uploaded by

Shruti Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views17 pages

Answer of Coding Exam 01

The document provides information about an online coding test for students in various branches for year 2nd, 3rd or 4th. It contains 40 multiple choice questions related to computer programming codes in languages like C, C++, Python and Java. The questions cover topics like data types, operators, control structures, functions, classes, inheritance, polymorphism, exceptions, arrays and strings.

Uploaded by

Shruti Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Date : September 30, 2023

2023-24 (Odd Semester)


Branch : CE/CSE/EC/EE/EN/IT/ME
Year : 2nd / 3rd / 4th

ANSWER KEY OF ONLINE PREPRATION


MODULE OF T&P CELL

CODING TEST-01
[[[

BABU BANARASI DAS


NORTHERN INDIA INSTITUTE OF TECHNOLOGY
LUCKNOW
BBDNIIT Preparation Module for
Placement Drive
[email protected] Switch account Draft saved

Computer Programming Code

This Section has 40 questions and each question carry equal marks.

Q1. The number of tokens in C Language, printf(“i = %d, &i – %x”, i, &i); 1 point

a. 3

b. 10

c. 25

d. 12

Clear selection

Q2. Let x be an integer which can take a value of 0 or 1. The statement in C, 1 point

if(x = =0) x = 1; else x = 0; is equivalent to which one of the following?

a. x = 1 + x;

b. x = 1 - x;

c. x = x - 1;

d. x = 1 % x;

Clear selection
Q3. Suppose that in a C program snippet, followings statements are used. 1 point

a. Only i) would compile successfully and it would return size as 4

b. i), ii) and iii) would compile successfully and size of each would be same i.e. 4

c. i), ii) and iii) would compile successfully but the size of each would be different
and would be decided at run time.

d. ii) and iii) would result in compile error but i) would compile and result in size as 4.

Clear selection

Q4. Which of the following statements are used in Exception Handling in 1 point

Python?

a. try

b. except

c. finally

d. All of the above

Clear selection
Q5. Assume int is 4 bytes, char is 1 byte and float is 4 bytes. Also, assume 1 point

that pointer size is 4 bytes (i.e. typical case)

a. 4 4 4

b. 1 4 4

c. 1 4 8

d. None of the Above

Clear selection

Q6. Which of the following is the proper syntax to check if a particular 1 point
element is present in a list?

a. if ele in list

b. if not ele not in list

c. Both of a and b

d. None of the above

Clear selection

Q7. Which of the following functions converts date to corresponding time in 1 point

Python?

a. strptime()

b. strftime()

c. Both A and B

d. None of the above

Clear selection
Q8. Which of the following statement is correct for switch controlling 1 point
expression?

a. Only int can be used in “switch” control expression

b. Both int and char can be used in “switch” control expression

c. All types i.e. int, char and float can be used in “switch” control expression

d. “switch” control expression can be empty as well.

Clear selection

Q9. Which of the followings is/are automatically added to every class, if we 1 point
do not write our own.

a. Copy Constructor

b. Assignment Operator

c. A constructor without any parameter

d. All of the above

Clear selection
Q10. Find the output of given program- 1 point

a. Compiler Error

b. 10 followed by Garbage Value

c. 10 10

d. 10 0

Clear selection

Q11. What is the difference between struct and class in C++? 1 point

a. Members of a class are private by default and members of struct are public by
default. When deriving a struct from a class/struct, default access-specifier for a
base class/struct is public and when deriving a class, default access specifier is
private.

b. All members of a structure are public and structures don't have constructors and
destructors

c. All members of a structure are public and structures don't have virtual functions

d. All of the above

Clear selection
Q12. A member function can always access the data in __________ , (in C++). 1 point

a. the object of which it is a member

b. the public part of its class

c. the class of which it is member

d. the private part of its class

Clear selection

Q13. Which of the following is not correct (in C++) ? 1 point

a. 1

b. 2, 4

c. 4

d. 2, 3, 4

Clear selection

Q14. Can destructors be private in C++? 1 point

a. Yes

b. No

Clear selection

Q15. Which of the following are valid string manipulation functions in 1 point
Python?

a. count()

b. upper()

c. strip()

d. All of the above

Clear selection
Q16. Predict the output of following C++ program. 1 point

a. x = 5

b. x = 10

c. Compiler Error

d. Runtime Error

Clear selection

Q17. Which of the following in Object Oriented Programming is supported by 1 point


Function overloading and default arguments features of C++.

a. Inheritance

b. Polymorphism

c. Encapsulation

d. None of the above

Clear selection
Q18. If a function is friend of a class, which one of the following is wrong? 1 point

a. A function can only be declared a friend by a class itself.

b. Friend functions are not members of a class, they are associated with it.

c. Friend functions are members of a class.

d. It can have access to all members of the class, even private ones

Clear selection

Q19. How to create a dynamic array of pointers (to integers) of size 10 using 1 point
new in C++? Hint: We can create a non-dynamic array using int *arr[10]

a. int *arr = new int *[10];

b. int **arr = new int *[10];

c. int *arr = new int [10];

d. Not Possible

Clear selection

Q20. What is the advantage of exception handling ? 1 point

a. Only 1

b. 1, 2 and 3

c. 1 and 2

d. 1 and 3

Clear selection
Q21. Which of the following is FALSE about abstract classes in Java 1 point

a. If we derive an abstract class and do not implement all the abstract methods, then
the derived class should also be marked as abstract using 'abstract' keyword

b. A class can inherit from multiple abstract classes

c. Abstract classes can have constructors

d. A class can be made abstract without any abstract method

Clear selection

Q22. Type IV JDBC driver is a driver 1 point

a. which is written in C++

b. which requires an intermediate layer

c. which communicates through Java sockets

d. which translates JDBC function calls into API not native to DBMS

Clear selection

Q23. Which of the following is FALSE about arrays on Java 1 point

a. A java array is always an object

b. Length of array can be changed after creation of array

c. Arrays in Java are always allocated on heap

d. All of the above

Clear selection
Q24. Predict the output of the following program. 1 point

a. a = 10

b. a = 20

c. Compilation error

d. None of these

Clear selection
Q25. Predict the output in Java? 1 point

a. 10 20 30 40 50

b. 10 20 30 40

c. Compiler Error

d. None of given

Clear selection

Q26. Which of the following is/are advantages of packages? 1 point

a. Packages avoid name clashes

b. Classes, even though they are visible outside their package, can have fields visible
to packages only

c. We can have hidden classes that are used by the packages, but not visible outside.

d. All of the above

Clear selection
Q27. Output of following Java Program? 1 point

a. Base::show() called

b. Derived::show() called

c. Compiler Error

d. Runtime Error

Clear selection

Q28. Which one of the following is correct? 1 point

a. Java applets can not be written in any programming language

b. An applet is not a small program

c. Applets are embedded in another applications

d. An applet can be run on its own

Clear selection

Q29. Which of the following is not an operator in Java? 1 point

a. instanceof

b. new

c. sizeof

d. >>>=

Clear selection
Q30. Find the output in java- 1 point

a. i = 10, j = 20

b. i = 20, j = 10

c. i = 10, j = 10

d. i = 20, j = 20

Clear selection

Q31. What is the output of the following code in python : 1 point

a. Error

b. None

c. abcd

d. [‘a’,’b’,’c’,’d’]

Clear selection
Q32. What is the output of the following program : 1 point

a. 48

b. 14

c. 64

d. None of the above

Clear selection

Q33. What is called when a function is defined inside a class? 1 point

a. Module

b. Class

c. Another Function

d. Method

Clear selection

Q34. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)? 1 point

a. [3, 4, 5, 20, 5, 25, 1, 3]

b. [1, 3, 3, 4, 5, 5, 20, 25]

c. [3, 5, 20, 5, 25, 1, 3]

d. [1, 3, 4, 5, 20, 5, 25]

Clear selection
Q35. Consider the results of a medical experiment that aims to predict 1 point
whether someone is going to develop myopia based on some physical
measurements and heredity. In this case, the input dataset consists of the
person’s medical characteristics and the target variable is binary: 1 for those
who are likely to develop myopia and 0 for those who aren’t. This can be best
classified as

a. Regression

b. Decision Tree

c. Clustering

d. Association Rules

Clear selection

Q36. What is the output of the following program : print 0.1 + 0.2 == 0.3 1 point

a. True

b. False

c. Machine dependent

d. Error

Clear selection

Q37. Which of these is not a core data type in python? 1 point

a. Lists

b. Dictionary

c. Tuples

d. Class

Clear selection
Q38. Which of the following statement(s) is TRUE? 1 point

a. only 1

b. 2 and 3

c. 1 and 3

d. only 2

Clear selection

Q39. What is the output of the expression : 3*1**3 1 point

a. 1

b. 3

c. 9

d. 27

Clear selection

Q40. What is the output of the following python program : 1 point

a. 0 1 2 0

b. 0 1 2

c. Error

d. None of the above

Clear selection

Back Submit Clear form

Never submit passwords through Google Forms.

You might also like