You are on page 1of 10

JAVA AND DSD

1. class Main {
public static void main (String args[ ])
{
System.out.println(f1 ());
}
int f1( )
{
return 50;
}
}
What is the output of the above code?

Ans: It gives compiler error. Because in java non static methods cannot be called in static
methods

2. class Main
{
public static void main (String args [])
{
int t=1;
if(t)
{
System.out.println("Hello");
}
else
{
System.out.println("Hi");
}
}
}

The output of the above program is

Ans: Compiler error.

Incompatible types: int is not converted to Boolean in java. This works only in C/C++.

3. class Main
{
public static void main (String args [])
{
String x = new String("nmamit");
String y = new String ("nmamit");
if (x == y)
System.out.println("Equal");
else
System.out.println("Not equal");
}
}
The output of the above program is

Ans: Output is- Not equal.


x and y are two different objects, hence the references are not the same.
In order to compare strings use string.equals( ) method.

4. Which of the following is the correct defenition of abstract class?


Ans: abstract class A { abstract void fun();} is the correct definition.
Use abstract keyword to define abstract class and define an abstract function in the same.

5. Which of the following methods of Thread class is used to obtain the priority of a given
thread?
Ans: getPriority()

6. Suppose A is an abstract class and B is a concrete subclass of A and both have default
constructors
Which of the following is correct?

1. A a = new A( );
2. A a = new B( ):
3. B b = new B( );
4. B b = new A( );
Ans: 2 and 3 are correct.
Only concrete classes can be instantiated. Abstract class reference variable can be created.

7. Java's built in exceptions are present in this package


Ans: java.lang

8. Which of the following does not allow storing null values?


Ans: TreeSet does not allow storing null values. It gives NullPointerException.
HashSet and LinkedHashSet allow null values, but only one null value.

9. Which of the following does not implement Collection interface?


Ans: Map does not implement Collection interface where as List and Set do.

10. The reduced form of Y = AB’ + (A’ + B) C.


Ans: Y = AB’ + (A’ + B)C = AB’ + (AB’)’ C
= (AB’ + C ) ( AB’ + (AB’)’) = (AB’ + C).1 = AB’ + C

11. Product-of-Sums expressions can be implemented using


Ans: Both 2-level NOR and 2-level OR-AND logic circuit

12. SR flip flop can be used as


Ans: Switch bouncer
The SR flip-flop is very effective in removing the effects of switch bounce, which is the
unwanted noise caused during the switching of electronic devices.
13. Whose operations are faster among the following?
Combinatiobal circuits, Sequential circuits, Flip flops, Latches

Ans: Combinational circuits are often faster than sequential circuits. Combinational circuits do
not require memory elements whereas the sequential circuits need memory devices to perform
their operations in sequence. Latches and Flip-flops come under sequential circuits.

14. Which of the following is an ambiguous condition in a NAND- based S'-R' flip flop?
Ans: S’=0 and R’=0 is an ambiguous condition because both the output will be HIGH. In this case
system goes to an unexpected state.

15. A positive edge triggered D flip flop will store a 1 when


Ans: D input must be high and clock transitions from LOW to HIGH

16. Consider a 4 bit Johnson counter with an initial value of 0000. The counting sequence of this
counter is:
Ans: The four bit Johnson's counter connects the complement of the output of the last shift
register to the input of the first register ,1 bit will shift/cycle It will work as follows:
Inititally- 0000-0 //Last 0 complemented and fed as input to first register
1000 -8
1100-12
1110-14
1111-15 // last 1 complemented and 0 is fed to the first register
0111-7
0011-3
0001-1
0000-0
Hence the sequence is- 0,8,12,14,15,7,3,1,0

17. What is the minimum number of gates required to implement the Boolean function (AB+C)if
we have to use only 2-input NOR gates?
Ans: AB + C= (A + C)(B + C) = ((A+C)' + (B+C)')'
Hence 3 NOR gates are required

18. The primary difference between a counter and a register is


Ans: The primary difference between a counter and a register is that register has no specific state
sequence except in certain conditions.
COA

1.The technique used to store programs larger than the memory is ____________
a.Buffers b.Disks c.Overlays d.Extension registers
Answer : Overlays
Explanation: In this, only a part of the program getting executed is stored on the memory
and later swapped in for the other part

2.The time lost due to the branch instruction is often referred to as ____________
a.Delay b.Branch Penalty c.Latency d.Redundancy
Answer : Branch Penalty
Explanation: This time also retards the performance speed of the processor.

3.The problem where process concurrency becomes an issue is called as ___________


a.Banker's problem b.Belady's Anomaly c.Reader-writer problem d.Philosophers problem
Answer : Reader-writer problem

4.Complete the following analogy:- Registers are to RAM’s as Cache’s are to ___________
a.TLB b.Overlays c.Page Table d.Latency

Answer :TLB

5.The periods of time when the unit is idle is called as _____


a.Stalls b.Hazards c.Bubbles d.Both Stalls and Bubbles
Answer: Both Stalls and Bubbles
Explanation: The stalls are a type of hazards that affect a pipelined system.

6.The method of mapping the consecutive memory blocks to consecutive cache blocks is
called ______
a.Set associative b.Associative c.Indirect d.Direct
Answer: Direct
Explanation: This method is most simple to implement as it involves direct mapping of
memory blocks.

7. The most Flexible way of logging the return addresses of the subroutines is by using
_______
a.Stacks b.Memory Locations c.Registers d.None
Answer : Stacks
Explanation: The stacks are used as Logs for return addresses of the subroutines.

8.The next level of memory hierarchy after the L2 cache is _______


a.Secondary Storage b.TLB c.Register d.Main Memory
Answer : Register

9.In associative mapping, in a 16 bit system the tag field has ______ bits.
a.8 b.12 c.10 d.7
Asnswer : 12
Explanation: The Tag field is used as an id for the different memory blocks mapped to the
cache.

PYTHON:

1.Predict the output of following python program:


r = lambda q: q * 2
s = lambda q: q * 4
x=2
x = r(x)
x = s(x)
x = r(x)
print (x)
a.24 b.32 c.45 d.2
Answer : 32
Explanation : In the above program r and s are lambda functions or anonymous functions
and q is the argument to both of the functions.
In first step we have initialized x to 2. In second step we have passed x as argument to the
lambda function r, this will return x*2 which is stored in x.
That is, x = 4 now. Similarly in third step we have passed x to lambda function s, So x = 4*4.
i.e, x = 16 now.
Again in the last step, x is multiplied by 2 by passing it to function r. Therefore, x = 32.

2.What is the maximum possible length of an identifier?


a.16 b.32 c.64 d.None of these above
Answer :None of these above
Explanation: The maximum possible length of an identifier is not defined in the python
language. It can be of any number.

3.What is the output of the following program?


List = [True, 90, 10]
List.insert(2, 8)
print(List, "Sum is: ", sum(List))
a) [True, 90, 10, 8] Sum is: 108
b) [True, 90, 8, 10] Sum is: 109
c) TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
d) [True, 90, 8, 10] Sum is: 108
Answer :[True, 90, 8, 10] Sum is: 109
Explanation: The List is initially has 3 elements. The insert() adds element 8 at index 2,
moving element 10 at index 3 and the List becomes [True,90, 8, 10].
Boolean has an integer value of 1, thus sum becomes 1 + 90 + 8 + 10 = 109.

4.What is the output of the following program?


L = [1, 3, 5, 7, 9]
print(L.pop(-3), end = ' ')
print(L.remove(L[0]), end = ' ')
print(L)
a)5 1 [3, 7, 9]
b) 5 None [3, 7, 9]
c) 5 1 [3, 7, 9]
d) 5 None [1, 3, 7, 9]
Answer:5 None [3, 7, 9]
Explanation: pop() will delete and return the element whose index was passed as
parameter. L.pop(-3) will delete 5 and return 5, which is printed by print(). remove() does
return any value, it’s a void function. L[0] = 1,
L.remove(1) will delete 1 from the list and the list remains to be [3, 7, 9].

5.What is the output of the following program?


print(chr(ord(chr(97))))
a. a b.A c.97 d.error
Answer: a
Explanation: Outer chr and ord will cancel out and we will be left with chr(97) which will
return "a". So, option A is correct.

6.What will be the output of below Python code?


str1="Information"

print(str1[2:9])
a. ormat
b. formatio
c. orma
d. formati
Answer :
Ans : formati
Explanation: Concept of slicing is used in this question. In string slicing,the output is the
substring starting from the first given index position i.e 2 to one less than the second given
index position
i.e.(9-1=8) of the given string str1. Hence, the output will be "formati".

7.What will following Python code return?


str1="Stack of books"
print(len(str1))
a.11 b.15 c.14 d.13
Answer : 14
Explanation: len() returns the length of the given string str1, including spaces and
considering " " as a single character.

8.What will be the output of following Python code?


list1=[1,3,4,2]
x=list1.pop(2)

print(set([x]))
a.{1,2,4,2} b.{1,3,2} c.{2} d.{4}
Answer : {4}
The output of the following code is {4}

9.What will be the output of below Python code?


list1=[1,2,3,4,5,6]
print(list1[::-1])
a.[6,5,4,3,2,1] b.[1,2,3,4,5,6] c.[6,5,4,3] d.[1,2,3]
Answer :[6,5,4,3,2,1]
Explanation: [6,5,4,3,2,1] will be the output of below Python code.
Data Communication:
1. Which of the following is incorrect?

a. The difference between synchronous and asynchronous transmission is


the clocking derived from the data in synchronous transmission.
b. Batch processing is the preferred processing mode for telecommunication
operations.
c. Half-duplex line is a communication line in which data can move in two
directions, but not at the same time.
d. Teleprocessing combines telecommunications and DP techniques in
online activities.
ANS: b. Batch processing is the preferred processing mode for
telecommunication operations.

2. What OSI layer handles logical address to logical name resolution?

a. Transport
b. Physical
c. Presentation
d. Data Link
ANS: a. Transport

3. The interactive transmission of data within a time sharing system is best


suited to:

a. Simplex lines
b. Half-duplex lines
c. Full-duplex lines
d. Biflex-line
ANS: b. Half-duplex lines

4. In CRC there is no error if the remainder at the receiver is _____.

a. Non-zero
b. Zero
c. The quotient at the sender
d. Equal to the remainder at the sender
ANS: c. The quotient at the sender
5. Which of the following is an example of a client-server model?

a. TELNET
b. FTP
c. DNS
d. All of the above
ANS: d. All of the above

6. Ananya is setting up a small network in her home so that she can study for
her MCSE exams. She doesn't have a lot of money to spend on hardware, so
she wants to use a network topology that requires the least amount of
hardware possible. Which topology should she select?

a. Star
b. Bus
c. Token-Ring
d. Ethernet
ANS: b. Bus

7. Frames from one LAN can be transmitted to another LAN via the device:

a. Router
b. Bridge
c. Repeater
d. Modem
ANS: b. Bridge

8. The Internet Control Message Protocol (ICMP)

a. allows gateways to send error and control messages to other gateways


or hosts
b. provides communication between the Internet Protocol Software on
one machine and the Internet Protocol Software on another
c. reports error conditions to the original source, the source must relate
errors to individual application programs and take action to correct the
problem
d. All of the above
ANS: d. All of the above
9. How many bits internet address is assigned to each host on a TCP/IP internet
which is used in all communications with the host?

a. 16 – bits
b. 32 – bits
c. 48 – bits
d. 64 – bits
ANS: b. 32 – bits

You might also like