Advertisements
Advertisements
The keyword used by a class to acquire the properties of an interface is:
Concept: undefined > undefined
State the principle by which the stack data structure works.
Concept: undefined > undefined
Advertisements
A Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out).
Define a class Queue with the following details:
Class name | Queue |
Data member/instance variable: | |
dat[ ] | array to hold the integer elements |
cap | stores the maximum capacity of the queue |
front | to point the index of the front |
rear | to point the index of the rear |
Member functions/methods: | |
Queue(int max) | constructor to initialize the data member cap = max, front = rear = 0 and create the integer array |
void add_dat(int v) | to add integers from the rear index if possible else display the message(“Queue full”) |
int pop_dat( ) | to remove and return elements from front, if any, else returns -999 |
void display() | to display elements of the queue |
Specify the class Queue giving the details of void add_dat(int) and int pop_dat( ). Assume that the other functions have been defined.
The main( ) function and algorithm need NOT be written.
Concept: undefined > undefined
int Toy(int n)
{ return (n<=0)? 1: n%10 + Toy(n/10); }
With reference to the program code given above, what will the function Toy() return when the value of n = 56?
Concept: undefined > undefined
Give one reason, why iteration is better than recursion.
Concept: undefined > undefined
Differentiate between direct recursion and indirect recursion.
Concept: undefined > undefined
Assertion: For proposition ∼A=> B, its contrapositive is B =>∼A
Reason: Contrapositive is the converse of inverse for any proposition.
Concept: undefined > undefined
The complement of the Boolean expression (P' • Q) (R • S') is ______.
Concept: undefined > undefined
An array ARR [ -5 .....15, 10.....20] stores elements in Row Major Wise with each element requiring 2 bytes of storage. Find the address of ARR [10] [15] when the base address is 2500.
Concept: undefined > undefined
Draw the logic gate diagram for 2-input OR gate using NAND gates only. Show the expression at each Step.
Concept: undefined > undefined
Write the canonical form of the cardinal terms, m3 and M5 for F (A, B, C, D).
Concept: undefined > undefined
A class Ins Sort contains an array of integers which sorts the elements in a particular order.
Some of the members of the class are given below.
Class name | InsSort |
arr[ ] | stores the array elements |
size | stores the number of elements in the array |
Methods/Member functions: | |
InsSort(int s) | constructor to initialise size= s |
void getArray( ) | accepts the array elements |
void insertionSornt( ) | sorts the elements of the array in descending order using the in descending order using the Insertion Sort technique |
double find( ) | calculates and returns the average of all the odd numbers in the array |
void display( ) | displays the elements of the array in a sorted order along with the average of all the odd numbers in the array by invoking the function find( ) with an appropriate message |
Specify the class InsSort giving details of the constructor(), void getArray( ), void insertionSort( ), double find() and void display(). Define a main( ) function to create an object and call all the functions accordingly to enable the task.
Concept: undefined > undefined
Design a class Coding to perform some string related operations on a word containing alphabets only.
Example: Input: "Java"
Output: Original word: Java
J=74
a=97
v= 118
a=97
Lowest ASCII code: 74
Highest ASCII code: 118
Some of the members of the class are given below:
Class name | Coding |
Data members/instance variables: | |
wrd | stores the word |
len | stores the length of the word |
Methods/Member functions: | |
Coding() | constructor to initialise the data members with legal initial values |
void accept( ) | to accept a word |
void find() | to display all the characters of 'wrd' along with their ASCII codes. Also display the lowest ASCII code and the highest ASCII code, in 'wrd' |
void show() | to display the original word and all the characters of 'wrd' along with their ASCII codes. Also display the lowest ASCII code and the highest ASCII code in 'wrd', by invoking the function find() |
Specify the class Coding giving details of the constructor( ), void accept( ), void find( ) and void show(). Define a main() function to create an object and call all the functions accordingly to enable the task.
Concept: undefined > undefined
CardGame is a game of mental skill, built on the simple premise of adding and removing the cards from the top of the card pile.
The details of the class CardGame are given below.
Class name | CardGame |
Data members/instance variables: | |
cards[] | array to store integers as cards |
cap | to store the maximum capacity of array |
top | to store the index of the topmost element of the array |
Methods/Member functions: | |
CardGame(int cc) | constructor to initialise cap=cc and top= -1 |
void addCard(int v) | to add the card at the top index if possible, otherwise display the message “CARD PILE IS FULL” |
int drawCard( ) | to remove and return the card from the top index of the card pile, if any, else return the value -9999 |
void display( ) | to display all the cards of card pile |
- Specify the class CardGame giving details of the functions void addCard(int) and int drawCard( ). 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
A super class EmpSal has been defined to store the details of an employee. Defie a subclass (overtime to compute the total salary of the employee, after adding the overtime amount based on the following criteria.
- If hours are more than 40, then 5000 are added to salary as an overtime amount
- If hours are between 30 and 40 (both inclusive), then 3000 are added to salary as an overtime amount
- If hours are less than 30, then the salary remains unchanged The details of the members of both the classes are given below:
Class name | EmpSal |
Data members/instance variables: | |
empnum | to store the name of the employee |
empcode | integer to store the employee code |
salary | to store the salary of the employee in decimal |
Methods/Member functions: | |
EmpSal(...) | parameterised constructor to assign values to data members |
void show() | to display the details of the employee |
Class name | Overtime |
Data members/instance variables: | |
hours | integer to store overtime in hours |
totsal | to store the total salary in decimal |
Methods/Member functions: | |
Overtime(....) | parameterised constructor to assign values to data members of both the classes |
void calSal() | calculates the total salary by adding the overtime amount to salary as per the criteria given above |
void show() | to display the employee details along with the total salary (salary +overtime amount) |
Assume that the super class EmpSal has been defined. Using the concept of inheritance, specify the class Overtime giving the details of the constructer (...), void calSal() and void show().
The super class, main function and algorithm need NOT be written.
Concept: undefined > undefined
Assertion: Recursion utilises more memory as compared to iteration.
Reason: Time complexity of recursion is higher due to the overhead of maintaining the function call stack.
Concept: undefined > undefined
Study the given propositions and the statements marked Assertion and Reason that follow it. Choose the correct option on the basis of your analysis.
p = I am a triangle
q = I am a three-sided polygon
s1 = p → q
s2 = q → p
Assertion: s2 is converse of s1
Reason: Three-sided polygon must be a triangle.
Concept: undefined > undefined
Assertion: In Java, the String class is used to create and manipulate strings, and it is immutable.
Reason: Immutability ensures that once a String object is created, its value cannot be changed.
Concept: undefined > undefined
A full adder needs five gates and those are 3 AND gates, 1 OR gate and 1 XOR gate. When a full adder is constructed using 2 half adders, it also requires 5 gates. State the names along with the quantity those gates.
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