Advertisements
Advertisements
When a sequence of OR, NOT, NOR are connected in series, the logic gate obtained is ______.
Concept: undefined > undefined
Idempotence Law states that ______.
Concept: undefined > undefined
Advertisements
Assertion: Recursive data structure follows the LIFO principle.
Reason: Execution of recursive code follows the concepts of data structure Queue.
Concept: undefined > undefined
State any one difference between instance variable and class variable.
Concept: undefined > undefined
The following function is a part of some class:
int jolly(int[] x, int n, int m)
{
if (n<0)
return m;
else if(n<x.length)
m=(x[n]>m)?x[n]:m;
return jolly(x, --n, m);
}
- What will be the output of jolly() when the value of x[ ]={6,3,4,7,1}, n=4 and m=0?
- What function does jolly() perform, apart from recursion?
Concept: undefined > undefined
Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.
Concept: undefined > undefined
Design a class DeciHex to accept a positive integer in decimal number system from the user and display its hexadecimal equivalent.
Example 1:
Decimal number= 25
Hexadecimal equivalent= 19
Example 2:
Decimal number =28
Hexadecimal equivalent = 1C
Some of the members of the class are given below.
Class name | DeciHex |
Data members/instance variables: | |
num | stores the positive integer |
hexa | string to store the hexadecimal equivalent of num |
Methods / Member functions: | |
DeciHex() | constructor to initialise the data members with legal initial values |
void getNum() | to accept a positive integer |
void convert(int n) | to find the hexadecimal equivalent of the formal parameter 'n' using the recursive technique |
void display() | to display the decimal number and its hexadecimal equivalent by invoking the function convert() |
Specify the class DeciHex giving details of the constructor( ), void getNum( ), void convert(int) and void display(). Define a main() function to create an object and call all the functions accordingly to enable the task.
Concept: undefined > undefined
Draw the logic circuit for 3:8 decoder (Octal decoder). Which multiplexer can be derived from the Octal decoder?
Concept: undefined > undefined
Consider the following statement written in class Circle where pi is its data member.
static final double pi = 3.142;
Which of the following statements are valid for pi?
- It contains a common value for all objects class Circle.
- Its value is non-changeable.
- At a time two access modifiers, static and final, cannot be applied to a single data member pi.
Concept: undefined > undefined
A matrix M[-6….10, 4…15] is stored in the memory, with each element requiring 4 bytes of storage. If the base address is 1025, find the address of M[4][8] when the matrix is stored in column major-wise.
Concept: undefined > undefined
The following function getIt() is a part of some class. Assume x is a positive integer, f is the lower bound of arr[ ] and l is the upper bound of the arr[ ].
Answer the questions given below along with dry run/working.
public int getIt(int x,intarr[],int f,int l)
{
if(f>l)
return-1;
int m=(f+l)/2;
if(arr[m]<x)
return getIt(x,m+1,l);
else if(arr[m]>x)
return getIt(x,f,m-1);
else
return m;
}
- What will the function getIt( ) return if arr[ ] = {10,20,30,40,50} and x = 40?
-
What is function getIt( ) performing apart from recursion?
Concept: undefined > undefined
Draw the logic circuit to decode the following binary number (0001, 0101, 0111, 1000, 1010, 1100, 1110,1111) to its hexadecimal equivalents. Also, state the Hexadecimal equivalents of the given binary numbers.
Concept: undefined > undefined
The following is a function of class Armstrong. This recursive function calculates and returns the sum of the cubes of all the digits of num, where num is an integer data member of the class Armstrong.
[A number is said to be Armstrong if the sum of the cubes of all its digits is equal to the original number].
There are some places in the code marked by ?1?, ?2?,?3? which may be replaced by a statement/expression so, that the function works properly.
public int sumOfPowers(int num)
{
if(num == 0)
return ?1?
int digit = ?2?;
return(int)Math.pow(digit, 3) + ?3?;
}
- What is the expression or statement at ?1?
- What is the expression or statement at ?2?
- What is the expression or statement at ?3?
Concept: undefined > undefined
A class LCM has been defined to find the Lowest Common Multiple of two integers.
Some of the data members and member functions are given below:
Class name | LCM |
Data members/instance variables: |
|
n1 | to store an integer number |
n2 | to store an integer number |
large | integer to store the largest from n1,n2 |
sm | integer to store the smallest from n1,n2 |
l | to store lcm of two numbers |
Methods / Member functions: | |
LCM( ) | default constructor to initialize data members with legal initial values |
void accept() | to accept n1 and n2 |
int getLCM() | returns the lcm of n1 and n2 using the recursive technique |
void display( ) | to print the numbers n1, n2 and lcm |
Specify the class LCM giving details of the constructor( ), void accept( ), int getLCM() and void display( ). Define a main ( ) function to create an object and call the member functions accordingly to enable the task.
Concept: undefined > undefined
The following function is a part of some class which is used to find the smallest digit present in a number. There are some places in the code marked by ?1?, ?2?, ?3? which must be replaced by an expression/a statement so that the function works correctly.
int small_dig(int n)
{ int min=?1?;
while(n!=0)
{
int q=n/10;
int r=?2?*10;
min=r>min ? ?3? : r;
n=q;
}
return min;
}
- What is the expression or statement at ?1?
- What is the expression or statement at ?2?
- What is the expression or statement at ?3?
Concept: undefined > undefined
Recycle is an entity which can hold at the most 100 integers. The chain enables the user to add and remove integers from both the ends i.e. front and rear.
Define a class ReCycle with the following details:
Class name | ReCycle |
Data members/instance variables: | |
ele[ ] | the array to hold the integer elements |
cap | stores the maximum capacity of the array |
front | to point the index of the front |
rear | to point the index of the rear |
Methods / Member functions: | |
ReCycle (int max) | constructor to initialize the data cap = max, front = rear = 0 and to create the integer array. |
void pushfront(int v) | to add integers from the front index if possible else display the message(“full from front”). |
int popfront( ) | to remove the return elements from front. If array is empty then return-999 |
void pushrear(int v) | to add integers from the front index if possible else display the message(“full from rear”). |
int poprear( ) | to remove and return elements from rear. If the array is empty then return-999. |
- Specify the class ReCycle giving details of the functions void pushfront(int) and int poprear( ). Assume that the other functions have been defined.
The main( ) function and algorithm need NOT be written. - Name the entity described above and state its principle.
Concept: undefined > undefined
Convert the following infix notation to postfix notation:
A * (B + C / D ) – E / F
Concept: undefined > undefined
Verify if (A + A')' is a Tautology, Contradiction or a Contingency.
Concept: undefined > undefined
Convert the following infix notation to prefix notation.
(A - B)/C * (D + E)
Concept: undefined > undefined
A shopping mall allows customers to shop using the cash or credit card of any nationalised bank. In awards bonus points to their customers on the basis of criteria given below:
- The customer is an employee of the shopping mall and makes the payment using a credit card.
OR - The customer shops items which carry bonus points and makes the payment using a credit card with a shopping amount of less than ₹10,000.
OR - The customer is not an employee of the shopping mall and makes the payment not through a credit card in cash for the shopping amount above ₹10,000/-
The inputs are:
INPUTS | |
C | Payment through a credit card. |
A | Shopping amount in above ₹10,000 |
E | The customer is an employee of the shopping mall. |
I | Item carries a bonus point. |
(In all the above cases, 1 indicates yes and 0 indicates no.)
Output: X[1 indicates bonus point awarded, 0 indicates bonus point not awarded for all cases]
Draw the truth table for the inputs and outputs given above and write the POS expression for X(C, A, F, I).
Concept: undefined > undefined