The aptitude test consisted tricky questions on core subjects of CSE like C , C++, Java ,Data Structures, Database, Computer Networks, Theory of Computation.
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
Technical aptitude Test 1 CSE
1. Walchand College Of Engineering,Sangli
ORGANIZES
Technical Aptitude Test
ASSOCIATION of Computer Science & Engg. STUDENTS
Date:21 July,2015
By Sujata Regoti
2. 1.What will be output when you will execute following c code?
#include<stdio.h>
void main()
{
int a=5;
a=a>=4;
switch(2)
{
case 0:int a=8;
case 1:int a=10;
case 2:++a;
case 3:printf("%d",a);
}
}
A. 2
B. 10
C. Compilation error
D. no output
E x p l a n a t i o n :
We can not declare any variable in any case of switch case
statement.
1
3. 2.What is the infix version of the following postfix expression?
x 12 + z 17 y + 42 * / +
A. (x + 12 + z) / (17 + y * 42)
B. x + 12 + z / 17 + y * 42
C. x + 12 + z / (17 + y) * 42
D. x + 12 + z / ((17 + y) * 42)
E. x + (12 + z) / (17 + y * 42)
2
4. 3. If we use mergesort to sort an array with n elements, what
is the worst case time required for the sort?
A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
E. O(n2)
1
5. 4.Output of following C++ code is
int &check()
{
static int num = 30;
return num;
}
int main()
{
check () = 40;
cout << check ();
return 0;
}
A.Compiler Error: lvalue required
B.40
C.30
D.0
Exp: When a function returns by reference, it can be used as lvalue. Since x
is a static variable, every call to fun() will not assign 30
1
6. 5.Output of following C++ code is (consider int 4 bytes)
#include <stdio.h>
int cse;
int main()
{
struct cse { double x; };
printf("%d", sizeof(cse));
return 0;
}
A. 8
B. 2
C. 4
D. Compiler error
Expl : In cpp struct keyword not required to use with variable name. So cse
hides global variable cse
1
7. 6 .What is output of following C++ code
#include<iostream>
class Test {
public :
int s;
Test(int s){
this->s=s;
}
static Test & fun() {
return this; }
};
int main()
{
Test t1(20),t2(30);
t2=t1.fun();
std::cout << t2.s;
}
A.20
B. Compilation error
C.30
D. Runtime error
//error: this is unavailable for static member functions
1
8. 7.What is the output for the below java code ?
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}
A.7 9 0
B.7 0 0
C.Compile error - $7 is not valid identifier.
D.Compile error - do is not valid identifier.
Expl: do is keyword
1
9. 8. What is expected output
public class Test{
public static void main(String[] args) {
String s=null;
System.out.println(null+s);
}
}
A.Runtime Exception thrown
B.null
C.nullnull
D.Compiler error
1
10. 9.What is expected output
public static void main(String[] args)
{
String s="";
StringBuffer sb="";
int i=5;
if(i<0)
s.concate("java rock");
else
sb.append("java rock");
System.out.println(s+sb);
}
A.javarock
B.javarock javarock
C.Compilation error
D.No output
E.Runtime error
Exp. :We cant directly assign string to stringbuffer So Error :incompatible
types at Line StringBuffer sb=“”; It should be sb=new StringBuffer(“”);
2
11. 10. How can this program be modified to make use of appropriate generic
types? (one modification for each line)
//Choose 3 options
import java.util.*;
public class Test {
public static void main(String[] args) {
List ids = new ArrayList(); // Line 1
ids.add(123);
ids.add(999);
Map students = new HashMap(); // Line 2
students.put("Jess",ids.get(0));
students.put("Jimmy",ids.get(1));
int x = ((Long)students.get("Jimmy")).intValue(); // Line3
}
}
A. replace line 1 with List<Integer> ids = new ArrayList<Integer>();
B. replace line 1 with List<Long> ids = new ArrayList<Long>();
C. replace line 2 with Map<Integer,String> students = new
HashMap<Integer,String>();
D. replace line 2 with Map<String,Integer> students = new
HashMap<String,Integer>();
E. replace line 3 with int x = students.get("Jimmy");
2
12. 11. class Test
{
public static void main(String[] args) {
Integer i = new Integer(0);
Float f = new Float(0);
System.out.println(i==f);
System.out.println(i.equals(f));
}
}
O/p is:
A. true false
B. false true
C. true true
D. Compiler error
Explanation :error: incomparable types:Integer and Float
1
13. 12. Which of the following are not a valid declarations?
A. float f = 1;
B. float f = 1.2f;
C. float f = 1.2;
D. float f = (float)1.2;
Explanation : By Default real number is double which cant be
directly assigned to float . So 3rd declaration throws error :
possible loss of precision occur.
1
14. 13. A process executes the code
fork();
fork();
fork();
The total number of child processes created is
A. 8
B. 7
C. 6
D. 3
2
15. 14.Which of the following memory allocation scheme suffers from
external fragmentation ?
A. Segmentation
B. Pure demand paging
C. Swapping
D. Paging
Explanation :
External fragmentation occurs in systems that use pure
segmentation.Because each segment has varied size to fit each program
size, the holes (unused memory) occur external to the allocated memory
partition.
1
16. 15.Which of the following concurrency control protocols ensure both
conflict serializability and freedom from deadlock?
I. 2-phase locking
II. Time-stamp ordering
A. I only
B. II only
C. Both I and II
D. Neither I nor II
2 Phase Locking (2PL) is a concurrency control method that guarantees
serializability. The protocol utilizes locks, applied by a transaction to data,
which may block (interpreted as signals to stop) other transactions from
accessing the same data during the transaction’s life. 2PL may be lead to
deadlocks that result from the mutual blocking of two or more transactions.
See the following situation, neither T3 nor T4 can make progress.
Timestamp-based concurrency control algorithm is a non-lock concurrency
control method. In Timestamp based method, deadlock cannot occur as no
transaction ever waits.
1
17. 16.Consider the following relational schema:
Employee (empId, empName, empDept )
Customer (custId,custName, salesRepId, rating)
SalesRepId is a foreign key referring to empId of the employee relation.
Assume that each employee makes a sale to at least one customer. What
does the following query return?
SELECT empName
FROM Employee E
WHERE NOT EXISTS (SELECT custId
FROM customer C
WHERE C. salesRepId = E. empId
AND C. rating < > ‘GOOD’)
A. Names of all the employees with at least one of their customers having a
‘GOOD’ rating.
B. Names of all the employees with at most one of their customers having a
‘GOOD’ rating.
C. Names of all the employees with none of their customers having a
‘GOOD’ rating.
D. Names of all the employees with all their customers having a ‘GOOD’
rating.
2
18. 16. Explanation
The outer query will return the value (names of employees) for a tuple in
relation E, only if
inner query for that tuple will return no tuple (usage of NOT EXISTS).
The inner query will run for every tuple of outer query. It selects cust-id for
an employee e, if
rating of customer is NOT good. Such an employee should not be selected
in the output of
outer query.
So the query will return the names of all those employees whose all
customers have GOOD
rating.
2
19. 17.Consider different activities related to email.
m1:Send an email from a mail client to mail server
m2:Download an email from mailbox server to a mail client
m3:Checking email in a web browser
Which protocol is applicable in each activity?
A. m1:HTTP, m2:SMTP, m3:POP
B. m1:SMTP, m2:FTP, m3:HTTP
C. m1:SMTP, m2:POP, m3:HTTP
D. m1:POP, m2:SMTP, m3:IMAP
Simple Mail Transfer Protocol (SMTP) is typically used by user clients for
sending mails.
Post Office Protocol (POP) is used by clients for receiving mails.
Checking mails in web browser is a simple HTTP process.
1
20. 18. A layer-4 firewall ( a device that can look at all protocol headers up to
the transport layer) CANNOT
A. block HTTP traffic during 9:00PM and 5:00AM
B. block all ICMP traffic
C. stop incoming traffic from a specific IP address but allow outgoing
traffic to same IP
D. block TCP traffic from a specific user on a specific IP address on multi-
user system during 9:00PM and 5:00AM
Exp: HTTP is an application layer protocol. Since firewal is at layer 4, it
cannot block HTTP data.
1
21. 19.Consider the following languages over the alphabet S = {0,1,c}
L1={ 0^n 1^n | n>=0}
L2={wcw^r |w ∈ {0,1}*}
L3={ww^r |w ∈ {0,1}*}
Here w^r is the reverse of the string w. Which of these languages are
deterministic Context free languages?
A. None of the languages
B. Only L1
C. Only L1 and L2
D. All the three languages
Exp:For the languages L1 and L2 we can have deterministic push down
automata, so they are
DCFL’s, but for 3 L only non-deterministic PDA possible. So the language
L3 is not a deterministic CFL.
1
22. 20.The number of states in the minimal deterministic finite
automaton corresponding to the regular expression (0+1)*(10)
is
A. One
B. Three
C. Four
D. Two
1