Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

Find the linear inequalities for which the shaded area is the solution set in the figure given below.

Answer»

We have seen that the shaded region and origin are on the opposite side of the line 6x + 2y = 8 

For (0,0) we have 0 + 0 - 8 < 0 . So the shaded region satisfies the inequality 6x + 2y \(\ge\) 8. 

We have seen that the shaded region and origin are on the opposite side of the line x + 5y = 4 

For (0,0) we have 0 + 0 - 4 < 0 . So the shaded region satisfies the inequality x + 5y \(\ge\) 4 . 

We have seen that the shaded region and origin are on the same side of the line x + y = 4 

For (0,0) we have 0 + 0 - 4 < 0 . So the shaded region satisfies the inequality x + y \(\le\) 4 

We have seen that the shaded region and origin are on the same side of the line y = 3 

For (0,0) we have 0 - 3 < 0. So the shaded region satisfies the inequality y \(\le\) 3. 

Thus the linear inequation comprising the given solution set are +2y \(\ge\) 8,x + 5y \(\ge\) 4, x + y \(\le\)4, y \(\le\) 3

2.

If 2x + 3y = 17; 2x + 2 – 3y + 1 = 5, then (x, y) is………………A) (3, 2) B) (2, 3) C) (-2, 3) D) (3, -2)

Answer»

Correct option is (A) (3, 2)

\(2^x+3^y=17\)   _________(1)

and \(2^{x+2} - 3^{y+1}=5\)

\(\Rightarrow\) \(2^2.2^x-3.3^y=5\)

\(\Rightarrow\) \(4.2^x-3.3^y=5\)   _________(2)

Let \(2^x=X\;\&\;3^y=Y\)

Then equations (1) & (2) converts to

X + Y = 17    _________(3)

and 4X - 3Y = 5   _________(4)

Put Y = 17 - X from (3) into equation (4), we get

4X - 3 (17 - X) = 5

\(\Rightarrow\) 4X - 51 + 3X = 5

\(\Rightarrow\) 7X = 5+51 = 56

\(\Rightarrow\) X = \(\frac{56}7\) = 8

\(\therefore\) Y = 17 - X

= 17 - 8 = 9    (From (3))

\(\therefore\) X = 8

\(\Rightarrow\) \(2^x=8=2^3\)

\(\Rightarrow\) x = 3

and Y = 9

\(\Rightarrow\) \(3^y=9=3^2\)

\(\Rightarrow\) y = 2

Hence, (x, y) = (3, 2)

Correct option is A) (3, 2)

3.

The point of the form (a, – a) always lies on the line(A) x = a (B) y = – a (C) y = x (D) x + y = 0

Answer»

(D) x + y = 0

Taking option (d), x + y = a + (-a) = a – a = 0 [since, give point is of the form (a, -a)]

Hence, the point (a, – a) always lies on the line x + y = 0.

4.

Write whether True or False and justify your answer:The graph of the linear equation x + 2y = 7 passes through the point (0, 7).

Answer»

False.

Justification:

We have the equation, x + 2y = 7.

Substituting the values of x = 0 and y = 7 from the point (0, 7) in the equation,

We get,

0 + 2(7) = 14 ≠ RHS

Hence, the graph of the linear equation x + 2y = 7 passes through the point (0, 7).

5.

The value of P for which the pair of equations 2Px + 3y = 7, 2x + y = 6 has exactly one solution. A) 3 B) Any real number except 3 C) Any real number D) For no real P the system has solution

Answer»

Correct option is (B) Any real number except 3

For both lines has exactly one solution (unique solution), we have

\(\frac{a_1}{a_2}\neq\frac{b_1}{b_2}\)

\(\Rightarrow\) \(\frac{2P}2\neq\frac31\)

\(\Rightarrow\) \(P\neq3\)

Hence, for any real value of P except 3, the given pair of linear equations has exactly one solution.

Correct option is B) Any real number except 3

6.

Write whether True or False and justify your answer:The point (0, 3) lies on the graph of the linear equation 3x + 4y = 12.

Answer»

True

If we put x = 0 and y = 3 in LHS of the given equation, we find LHS = 3 x 0 + 4 x 3 = 0 + 12 = 12 = RHS

Hence, (0, 3) lies on the linear equation 3x + 4y = 12.

7.

The slope of the line passing through (2, 3) and (4, 7) is …………………. A) 2 B) 5/6C) 4 D) 1

Answer»

Correct option is (A) 2

Slope of the line passing through points (2, 3) and (4, 7) is \(m=\cfrac{y_2-y_1}{x_2-x_1}\)

\(=\frac{7-3}{4-2}=\frac{4}{2}=2\)

Correct option is A) 2

8.

The point of intersection of the lines x = 2016 and y = 2017 is …………… A) (2017, 2016) B) (0, 2017)C) (2016, 0) D) (2016, 2017)

Answer»

Correct option is (D) (2016, 2017)

Point of intersection of the lines x = 2016 and y = 2017 is (2016, 2017).

Correct option is D) (2016, 2017)

9.

The point of intersection of the line y = ax + b with X – axis is …………………A) (- b/a,0)B) ( b/a,0)C) (0, b/a,)D) (0, - b/a,)

Answer»

Correct option is (A) (- b/a, 0)

Equation of line X-axis is y = 0.

\(\therefore\) For point of intersection of line y = ax+b with X-axis (i.e., y = 0 line), we have

ax + b = 0

\(\Rightarrow\) \(x=\frac{-b}{a}\)

Hence, point of intersection is \(\left(\frac{-b}{a},0\right).\)

Correct option is A) (- b/a,0)

10.

Fill in the blanks with suitable words:Variations in the off springs is the characteristic of …………. reproduction.

Answer»

Variations in the off springs is the characteristic of Sexual reproduction.

11.

What is sexual reproduction?

Answer»

The Reproduction which involves the formation and fusion of male and female gametes is called sexual reproduction.

12.

Fill in the blanks with suitable words:There is much wastage of pollen grain in ……………. pollination.

Answer»

There is much wastage of pollen grain in Cross (wind) pollination.

13.

What is reproduction?

Answer»

Reproduction is one of the basic characteristics of living organisms by which they continue their progeny.

14.

Write the special features of wind pollinated flowers.

Answer»

Special features of wind pollinated flowers are. The flowers are generally small and dull colored. They produce large number of dry and light pollen grain. 

Ex : Sugar cane, Jawara, etc.

15.

Fill in the blanks with suitable words:Fertilization leads to the formation of ………….

Answer»

Fertilization leads to the formation of Zygote.

16.

Explain the modification of the insect pollinated flowers.

Answer»

In most plants cross pollination is brought about with help of insects. Like butterflies, moths and bees. Such flowers show certain modifications to attract insects. These modifications are “mainly concerned with the color of the petals, some flowers contain glands called nectaries which produce the nectar to attract the insects, that bring about cross pollination, flowers which open during night, usually have a dull coloration, but have an aromatic smell that attracts insects.

17.

What is the main characteristics of Angiosperms?

Answer»

The seed is en closed in the fruit. This is a characteristic feature of angiosperms.

18.

What are the changes take place in the flower after pollination and fertilization.

Answer»

1. The following changes take place after the fertilization. 

2. The diploid Zygote develops into an embryo .which later differentiates in to a seed, which later grows in to a new plant. 

3. Surrounding the embryo a nutritive tissue called endosperm is formed. 

4. The entire ovule now becomes the seed. 

5. The coverings to the ovule transform in to the seed coat. 

6. Ovary portion of the carpel gets transformed in to the fruit enclosing the seed. 

7. Petals, sepals and other parts of the flower fall off. 

8. Thus pollination and fertilization result in the formation of seed. Which is enclosed in the fruit.

19.

If y = 3, then the value of ‘x’ satisfying the equation 5/x + 3/y = 6 is ..........A) 3 B) 1/3C) - 1/3D) 1

Answer»

Correct option is (D) 1

\(\frac{5}{x}+\frac{3}{y} = 6\)

\(\because\) y = 3

\(\therefore\) \(\frac{5}{x}+\frac{3}{3} = 6\)

\(\Rightarrow\) \(\frac{5}{x}=6-1=5\)

\(\Rightarrow\) \(x=\frac55=1\)

Correct option is D) 1

20.

The radii of internal and external surfaces of a hollow spherical shell are 3 cm and 5 cm respectively. It is melted and recast into a solid cylinder of diameter 14 cm. Find the height of the cylinder.

Answer»

Let r1 and r2 be the internal and external base radii of spherical shell.

r1 = 3 cm, and r2 = 5 cm

Base radius of solid cylinder, r = 7 cm

Let the height of the cylinder = h

As per given statement:

The hollow spherical shell is melted into a solid cylinder, so

Volume of solid cylinder = Volume of spherical shell

πr2h = 4/3 π(r23 – r13)

⇨ 49h = 4/3(125 – 27)

or h = 8/3 cm

21.

The surface area of sphere is (576π) cm2. Find its volume.

Answer»

We know that

Surface area of the sphere = 4 πr2

By substituting the values

4 πr2 = 576π

On further calculation

r2 = 576/ 4 = 144

By taking square root

r = 12cm

We know that

Volume of the sphere = 4/3 πr3

By substituting the values

Volume of the sphere = 4/3 × π × (12)3

So we get

Volume of the sphere = 2304 π cm3

Therefore, the volume of the sphere is 2304 π cm3.

22.

A solid metal cone with base radius of 12 cm and height 24 cm is melted to form solid spherical balls of diameter 6 cm each. Find the number of balls thus formed.

Answer»

Let the number of balls formed are n

As per statement,

Volume of metal cone = Total volume of n spherical balls

Volume of cone = n(Volume of any spherical ball)

1/3 π r2 h = n (4/3 π r3)

122 x 24 = n x 108

or n = 32

Therefore, 32 spherical balls can be formed.

23.

Book is an example of ……………. A) prism B) circle C) cone D) cuboid

Answer»

Correct option is D) cuboid

24.

A cone of height 20 cm and radius of base 5 cm is made up of modelling clay. A child reshapes it in the form of a sphere. Find the diameter of the sphere.

Answer»

Radius of the cone = r = 5cm and

Height of the cone = h = 20cm

Let the radius of the sphere = R

As per given statement,

Volume of sphere = Volume of cone

4/3 πR3 = 1/3πr2h

4R3 = 5 × 5 × 20

R = 5 cm

Diameter of the sphere = 2R = 2 x 5 = 10 cm

25.

Find the volume of a sphere whose surface area is 154 cm2.

Answer»

We know that

Surface area of the sphere = 4 πr2

By substituting the values

4 πr2 = 154

On further calculation

4 × (22/7) × r2 = 154

So we get

r2 = (154 × 7)/ (4 × 22) = 49/4

By taking the square root

r = 7/2 cm

We know that

Volume of the sphere = 4/3 πr3

By substituting the values

Volume of the sphere = 4/3 × (22/7) × (7/2)3

So we get

Volume of the sphere = 179.67 cm3

Therefore, the volume of the sphere is 179.67 cm3

26.

Find the surface area of a sphere whose volume is 606.375 m3.

Answer»

We know that

Volume of the sphere = 4/3 πr3

By substituting the values

606.375 = 4/3 × (22/7) × r3

On further calculation

r3 = (606.375 × 3 × 7)/ 88

So we get

r3 = 144.703125

By taking cube root

r = 5.25m

We know that

Surface area of the sphere = 4 πr2

By substituting the values

Surface area of the sphere = 4 × (22/7) × 5.252

So we get

Surface area of the sphere = 346.5 m2

Therefore, the surface area of the sphere is 346.5 m2.

27.

Solve x + 2y = 5 and 2x – y = 0 using any non-graphical method.

Answer»

x + 2y = 5 …………… (1) 

2x-y = 0 ………… (2) 

2x = y ⇒ x = \(\frac{y}{2}\)

This value substitute in equation (1)

\(\frac{y}{2}\) + 2y = 5 ⇒ y + 4y = 10 

5y = 10 ⇒ y = 2 

This value substitute in equation (2) 

2x – 2 = 0 ⇒ 2x = 2 ⇒ x = 1 

∴ x = 1, y = 2.

28.

हेनरी फेयोल ने औद्योगिक साहस की प्रबन्धकीय प्रवृत्तियों को कितने भागों में विभाजित किया है ?(A) 14(B) 08(C) 03(D) 06

Answer»

सही विकल्प है (D) 06

29.

“Industrial and General Management’ की पुस्तक किसने लिखी थी ?(A) हेरल्ड, कून्टज व ओडोनेल(B) फ्रेडरिक टेलर(C) हेनरी फेयोल(D) डेविस मोरिस

Answer»

सही विकल्प है (C) हेनरी फेयोल

30.

In the given figure if l ∥m, then find x, y and z.

Answer»

Given l ∥m and AC is transversal. 

z = 40° (Alternate interior angles) 

l ∥m and AB is transversal and x + (y + z) = 180° (co-interior angles are supplementary) 

x + y + z = 180° 

(x + y) + 40° = 180° (co-interior angles are supplementary) (∵ z = 40°) 

x + y + 40° = 180° 

x + y + 40°-40° = 180° – 40° 

∴ x + y = 140° 

But x = y (given)

2x = 140°

∴ x = 140°/2 = 70° = y 

So, x = 70°, y = 70° and z = 40°

l||m and ac is the transversal 
so z=40 degree ( alternate interior angle)
x=60 degree ( alternate interior angle)
y= 180-(60+40)=80 degrees

31.

How glycolysis is regulated?

Answer»

Glycolysis is strongly regulated by the complex interplay between ATP consumption, NADH2 regeneration and regulation of various glycolytic enzymes like hexokinase, PFK-1, pyruvate kinase, etc. Besides, it is also controlled by hormones like glucagon, epinephrine and insulin.

32.

Where does glycolysis take place in a cell?

Answer»

Glycolysis takes place in the cytoplasm of a cell.

33.

Write SQL qureries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables TRANSPORT and TRIENote:PERKS is Freight Charages per kilometerTTYPE is Transport Vehicle TypeNote:NO is Driver NumberKM is Kilometer travelledNOP is number of travellers travelled in vehicleTDATE is Trip Date1. To display NO, NAME, TDATE from the table TRIP in descending order of NO.2. To display the NAME of the drivers from the table TRIP who are traveling by transport vehicle with code 101 or 103.3. To display the NO and NAME of those drivers from the table TRIP who travelled between ‘2015-02-10’ and ‘2015-04-01’.4. To display all the details from table TRIP in which the distance travelled is more than 100 KM in ascending order of NOP5. SELECT COUNT (*), TCODE From TRIP GROUP BY TCODE HAVNING COUnT (*) &gt; 1;6. SELECT DISTINCT TCODE from TRIP;7. SELECT A.TCODE, NAME, TTYPE FROM TRIP A, TRANSPORT B WHERE A. TCODE = B. TCODE AND KM &lt; 90;8. SELECT NAME, KM *PERKM FROM TRIP A, TRANSPORT B WHERE A. TCODE = B. TCODE AND A. TCODE = 105′;

Answer»

1. SELECT NO, NAME, TDATE FROM TRIP ORDER BY NO;

2. SELECT NAME FROM TRIP WHERE TCODE = 101 OR TCODE = 103;

3. SELECT NO AND NAME FROM TRIP WHERE ‘2015-02-10’ < TDATE < ‘2015-04-01’;

4. SELECT NO, NAME, TDATE, KM, TCODE FROM TRIP WHERE KM >100 ORDER BY NOP;

5. TO DISPLAY THE MORE THAN ONE COUNT OF TCODE FROM THE TABLE TRIP

6. TO DISPALY SEPERATE TCODE OF TABLE TRIP

7. TO DISPAY THE NAME AND CODE OF THOSE TRANS PORTERS, WHO HAVE TRAVELLED MORE THAN 90 KMS.

8. TO DISPLAY THE NAME AND EXPENDITARE OF A TRANSPORTER WHO HAVE TCODE AS 105.

34.

Write SQL queries for (a) to (g) and write the output for the SQL queries mentioned shown in (hi) to (h4) parts on the basis of table ITEMS and TRADERS :1. To display the details of all the items in ascending order of item names (i.e., INAME).2. To display item name and price of all those items, whose price is in the range of 10000 and 22000 (both values inclusive).3. To display the number of items, which are traded by each trader. The expected output of this query should be:4. To display the price, item name and quantity (i.e., qty) of those items which have quantity more than 150.5. To display the names of those traders, who are either from DELHI or from MUMBAI.6. To display the names of the companies and the names of the items in descending order of company names.7. Obtain the outputs of the following SQL queries based on the data given in tables ITEMS and TRADERS above.SELECT MAX (PRICE), MIN (PRICE) FROM ITEMS;SELECT PRICE*QTY FROM ITEMS WHERE CODE-1004;SELECT DISTINCT TCODE FROM ITEMS;SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE I.TCODE=T.TCODE AND QTY&lt; 100;

Answer»

1. SELECT INAME FROM ITEMS ORDER BY INAME ASC;

2. SELECT INAME, PRICE FROM ITEMS WHERE PRICE => 10000 AND PRICE =< 22000; (c) SELECT TCODE, COUNT (CODE) FROM ITEMS GROUP BY TCODE;

3. SELECT PRICE, INAME, QTY FROM ITEMS WHERE (QTY> 150);

4. SELECT TNAME FROM TRADERS WHERE (CITY = “DELHI”) OR (CITY = “MUMBAI”)

5. SELECT COMPANY, INAME FROM ITEMS ORDER BY COMPANY DESC;

6. (hi) 38000 

1200 

(h2)1075000 

(h3)T01 

T02 

TO3 

(h4) LED SCREEN 40 DISP HOUSE INC CAR GPS SYSTEM ELECTRONICS SALES

35.

Consider the following tables CARDEN and CUSTOMER and answer (b) and (c) parts of this question:1. Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it.2. Write SQL commands for the following statements:o To display the names of all the silver coloured cars.o To display names of car, make and capacity of cars in descending order of their sitting capacity.o To display the highest charges at which a vehicle can be hired from CARDEN.o To display the customer name and the corresponding name of the cars hired by them.3. Give the output of the following SQL queries:o SELECT COUNT(DISTINCT Make) FROM CARDEN;o SELECT MAX(Charges), MIN (Charges) FROM CARDEN;o SELECT COUNTS), Make FROM CARDEN;

Answer»

1. Primary Key of CARDEN = C code CARDEN 

Alternate Key = CarName: 

Primary key of Customer = Code 

Alternate Key of Customer = Cname 2

2. SELECT CarName From CARDEN

(i)  WHERE Color = “SILVER”;

(ii) SELECT CarName, Make, Capacity From 

 CARDEN ORDER BY Capacity DESC;

(iii) SELECT MAX(Charges) Frm CARDEN;

(iv) ELECT Cname, CarName From CARDEN, CUSTOMER WHERE CARDEN. Ccode = CUSTOMER. Ccode;

3. (i) 4 

  (ii) MAX(Charges) MIN (Charges) 35 112 

  (iii) 5 

  (iv) SX4 C Class

36.

What is the use of wildcard.

Answer»

The wildcard operators are used with the LIKE operator to search a value similar to a specific pattern in a column. There are 2 wildcard operators.

% – represents 0,1 or many characters – – represents a single number or character

37.

Write SQL queries for (a) to (f) and write the outputs for the SQL queries mentioned shown in (gl) to (g4) parts on the basis of tables PRODUCTS and SUPPLIERS1. To display the details of all the products in ascending order of product names (i.e., PNAME).2. To display product name and price of all those products, whose price is in the range of 10000 and 15000 (both values inclusive).3. To display the number of products, which are supplied by each suplier. i.e., the expected output should be;S01 2S02 2S03 14. To display the price, product name and quantity (i.e., qty) of those products which have quantity more thhn 100.5. To display the names of those suppliers, who are either from DELHI or from CHENNAI.6. To display the name of the companies and the name of the products in descending order of company names.7. Obtain the outputs of the following SQL queries based on the data given in tables PRODUCTS and SUPPLIERS above.SELECT DISTINCT SUPCODE FROM PRODUCTS;SELEC MAX (PRICE), MIN (PRICE) FROM PRODUCTS;SELECT PRICE*QTY FROM PRODUCTS WHERE PID = 104; (g4)SELECT PNAME, SNAME FROM PRODUCTS P, SUPPLIERS S WHERE E SUPCODE = S. SUPCODE AND QTY&gt;100;

Answer»

1. SELECT * FROM PRODUCTS ORDER BY PNAME ASC;

2. SELECT PNAME, PRICE FROM PRODUCTS WHERE ((PRICE => 10000) AND (PRICE = < 15000));

3. SELECT SUPCODE, COUNT (PID) FROM PRODUCTS GROUP BY SUPCODE;

4. SELECT PRICE, PNAME, QTY FROM PRODUCTS WHERE (QTY > 100);

5. SELECT SNAME FROM SUPPLIERS WHERE ((CITY = “DELHI”) OR (CITY = “CHENNAI”));

6. SELECT COMPANY, PNAME FROM PRO-DUCTS ORDER BY COMPANY DESC; 4

7. SOI1 

(gl)s02 

s03 

(g2) 28000 

1100 

(g3) 550000 

(g4) PNAME SNAME Vi 

DIGITAL CAMERA 14 X GETALL INC 

PENDRIVE16 GB GETALL INC

38.

While creating table ‘customer’, Rahul forgot to add column ‘price’. Which command is used to add new column in the table. Write the command to implement the same.

Answer»

ALTER TABLE CUSTOMER ADD PRICE NUMBER (10, 2).

39.

Write SQL queries for:1. To display name, fee, gender, joinyear about the applicants, who have joined before 2010.2. To display names of applicants, who are playing fee more than 30000.3. To display names of all applicants in ascending order of their joinyear.4. To display the year and the total number of applicants joined in each YEAR from the table APPLICANTS.5. To display the C_ID (i.e., CourselD) and the number of applicants registered in the course from the APPLICANTS and table.6. To display the applicant’s name with their respective course’s name from the tables APPLICANTS and COURSES.7. Give the output of following SQL statements:SELECT Name, Joinyear FROM APPLICANTS WHERE GENDER=’F’ and C_ID=’A02′;SELECT MIN (Joinyear) FROM APPLICANTS WHERE Gender=’m’;SELECT AVG (Fee) FROM APPLICANTS WHERE C_ID=’A0T OR C_ID=’A05′;SELECT SUM- (Fee), C_ID FROM C_ ID GROUP BY C_ID HAVING COUNT(*)=2;

Answer»

1. SELECT NAME,FEE,GENDER,JOINYEAR 

FROM APPLICANTS 

WHERE J OINYE AR <2010

2. SELECT NAME FROM APPLICANTS WHERE FEE >30000

3. SELECT NAME FROM APPLICANTS ORDERBY JOINYEAR ASC

4. SELECT YEAR, COUNT]*) FROM 

APPLICANTS GROUP BY YEAR;

5. SELECT C_ID, COUNT]*) FROM 

APPLICANTS, COURSES GROUP BY ID 

WHERE APPLICANTS.C_ID=COURSES. C_ID

6. SELECT NAME,COURSE FROM APPLICANTS, COURSES 

WHERE APPLICANTS. C_ID=COURSES. C_ID

  • Avisha 2009
  • 2009
  • 67
  • 55000 A01
40.

How is a static method different from an instance method?

Answer»

A static method has to be defined outside a class. It can be called without an object. An instance method is defined within a class and has to be invoked on an object.

41.

Explain Data Hiding with respect to OOP.

Answer»

Data hiding can be defined as the mechanism of hiding the data of a class from the outside world or to be precise, from other classes. Data hiding is achieved by making the members of the class private. Access to private members is restricted and is only available to the member functions of the same class. However, the public part of the object is accessible outside the class.

42.

Fill in the blanks:1. Act of representing essential features without background detail is called ______ .2. Wrapping up of data and associated functions into a single unit is called ______ .3. ______ is called the instance of a class.

Answer»

1. Data Abstraction

2. Encapsulation

3. Object

43.

List three features that make an important characteristic of OOP.

Answer»
  • Capability to express closeness with the real- world models.
  • Reusability-allows addition of new features to an existing one.
  • Transitivity-changes in one class get automatically reflected across.
44.

Is function overloading supported by Python? Give reasons.

Answer»

A given name can only be associated with one function at a time, so cannot overload a function with multiple definitions. If you define two or more functions with the same name, the last one defined is used. 

However, it is possible to overload a function, or otherwise genericized it. You simply need to create a dispatcher function that then dispatches to your set of corresponding functions. Another way to genericized a function is to make use of the simple generic module which lets you define simple single-dispatch generic

functions.

def test(): #function 1

print “hello”

def test(a, b): #function 2

return a+b

def test(a, b, c): #function 3

return a+b+c

If you run the code of three test functions, the second test() definition will overwrite the first one. Subsequently, the third test() definition will overwrite the second one. That means if you give the function call test (20,20), it will flash an error stating, “Type Error: add() takes exactly 3 arguments (2 givens)”. This is because Python understands the latest definition of the function test() which takes three arguments.

45.

List few disadvantages of OOP.

Answer»
  • Classes tend to be overly generalized.
  • Relationship among classes might become artificial.
  • Program design is tricky and complicated.
  • More skills and thinking in terms of objects is required.
46.

How do abstraction and encapsulation complement each other?

Answer»

Abstraction and Encapsulation are complementary concepts. Through encapsulation only we are able to enclose the components of the object into a single unit and separate the private and public members. It is through abstraction that only the essential behaviors of the objects are made visible to the outside world. 

So, we can say that encapsulation is the way to implement data abstraction. For example in class Student, only the essential information like roll no, name, date_of_birth, course, etc. of the student will be visible. The secret information like calculation of grades, allotment of examiners etc. will be hidden.

47.

Explain Function overloading with an example.

Answer»

When several function declarations are specified for a single function name in the same scope, the function is said to be overloaded. In other languages, the same function name can be used to define multiple functions with different number and type of arguments, def test(): 

#function 1 print “hello”

def test(a, b): #function 2

return a+b

def test(a, b, c): #function 3

return a+b+c 2

48.

What is the concept of overriding method? Give an example for the same.

Answer»

Overriding Methods: It is a method to access, the parameterized constructor with the same name but having different parameters. For example,

Class emp:

def_init_(self, n):

self, a = n def_init_(self):

self, a = 100

49.

Predict the output of the following program. Also state which concept of OOP is being implemented?def sum(x,y,z):print “sum= ”, x+y+zdef sum(a,b):print “sum= ”, a+bsum(10,20)sum(10,20,30)

Answer»

Type Error: sum() takes exactly 3 arguments (2 given)

Concept: Polymorphism [Function Overloading]

50.

Write a program that uses an area() function for the calculation of area of a triangle or a rectangle or a square. Number of sides (3, 2 or 1) suggest the shape for which the area is to be calculated.

Answer»

from functools import wraps

import math

def overloaded(func):

@wraps(func)

def overloaded_func(*args, **kwargs):

for f in overloaded_func.overloads:

try:

return f(*args, **kwargs)

except TÿpeError:

pass

else:

# it will be nice if the error message prints a list of

# possible signatures here

raise TÿpeError(“No compatible signatures”)

def overload_with(func):

overloaded_func.overloads.append(func)

return overloaded_func

overloadedjunc.overloads = [func]

overloaded_func.overload_with = overload_with

return overloaded_func

#############

©overloaded

def area():

print ‘Area’

pass

@area.overload_with

def _(a):

# note that, like property(), the function’s name in

# the “def _(n):” line can be arbitrary, the important

# name is in the “@overloads(a)” line

print ‘Area of square=’,a*a

pass

@area.overload_with

def _(a,b):

# note that, like property(), the function’s name in

# the “def _(nl,n2):” line can be arbitrary, the important t

# name is in the “@overloads(a)” line

print Area of rectangle=’,a*b

pass

@area.overload_with

def _(a.b,c):

s= (a+b+c)/2

print s

print Area of triangle=’, math.sqrt(s*(s-a)* (s-b)*(s-c))

pass

choice=input(“Enter 1-square 2-rectangle 3- tr-iangle”)

if choice==1:

side = input(“Enter side”) area(side)

elif choice ==2:

length = input(“Enter length”)

breadth = input(“Enter breadth”)

area(length,breadth) elif choice==3:

a = inputfEnter sidel”)

b = inputfEnter side2”)

c = inputfEnter side3”) area(a,b,c)

else:

print “Invalid choice”