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.

What is Object Oriented Programming? List some of its advantages.

Answer»

OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. 

Advantages:

  • Simplicity
  • Modifiability
  • Extensibility and Maintainability
  • Reusability
  • Security
2.

Explain polymorphism with an example.

Answer»

Polymorphism is the ability for a message or data to be processed in more than one form. An operation may exhibit different behaviors in different instances. For example, consider the operation of addition of two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation.

3.

Define binding. Differentiate between static and dynamic binding.

Answer»

Binding is the process of linking the function call to the function definition. The body of the function is executed when the function call is made. 

Binding can be of two types: 

Static Binding: In this type of binding, the linking of the function call to the function definition is done during compilation of the program. 

Dynamic Binding: In this type of binding, linking of a function call to the function definition is done at runtime. That means the code of the function that is to be linked with function call is unknown until it is executed.

4.

What is abstract method? Give a suitable example to illustrate the same.

Answer»

Abstract Method: An abstract method is a method defined in the base class, but does not require code for the implementation. 

e.g.,

Class teacher: def entry (self):

teach#=int(input(“Enter No”))

def display ( ):

print (self, teach #)

5.

How do we implement abstract method in python? Give an example for the same.

Answer»

Abstract method: An unimplemented method is called an abstract method. When an abstract method is declared in a base class the derived class has to define the method or raise “Notimplemented Error”

Or

Abstract Method can be used to enable parent class method execution.

Class Shape (object):

def findArea (self): pass

Class Square (Shape):

def init (self, side):

self, side = side def findArea self.side*self.side

6.

Write a program to find out volume of a cube, cuboid and cylinder using function overloading.

Answer»

from functools import wraps import math def overloaded(func):

@wraps(func)

def overloaded_funcfargs, **kwargs):

for f in overloaded_func.overloads:

try:

return ff args, **kwargs)

except TypeError:

pass 1

else:

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

# possible signatures here raise

TypeError(“No compatible signatures”)

def overload_with(func):

overloaded_func.overloads.append(func)

return overloaded_func

overloaded_func.overloads = [func]

overloaded_func.overload_with = overload_with

return overloaded_func #############

@overloaded

def volume():

print ‘Volume’

pass

@volume.overload_with def _(a):

print ‘Volume of cube=’,a*a*a, ‘cubic units’

pass

@volume.overload_with def _(a,b):

print ‘Volume of cylinder, 3.14*a*a*b,‘cubic units’

pass

@volume.overload_with def _(a,b,c):

print ‘Volume of cuboid=’, a*b*c, ‘cubic units’

pass

choice = input(“Enter 1-cube 2-cylinder 3-cuboid”)

if choice==1:

side = input(“Enter side”)

volume (side)

elif choice ==2:

radius = input(“Enter radius”)

height = input( “Enter height”)

volume(radius,height)

elif choice==3:

length = input(“Enter length”)

breadth = input(“Enter breadth”)

height = input(“Enter height”)

volume (length, breadth, height)

else:

print “Invalid choice”

7.

Differentiate between an object and a class.

Answer»

A class is a collection of objects of similar type.

For example, mango, apple and orange are members of the class fruit. Classes are user-defined data types and behave like the built-in types of a programming language.

The syntax used to create an object is not different than the syntax used to create an integer object in C. If the fruit has been defined as a class, then the statement fruit mango; will create an object mango belonging to the class fruit.

8.

Give a suitable example using Python code to illustrate single level inheritance considering COUNTRY to be BASE class and STATE to be derived class.

Answer»

Class COUNTRY: statejist = [ ]

def_init_(self, name):

self.name = name class state (COUNTRY):

def_init_(self, name, capital): super ( )._init_(name)

self.capital = capital

9.

Consider the figure given below and answer the questions that follows:1. Name the base class and the derived class.2. Which concept of OOP is implemented in the figure given above?

Answer»

1. Base class – STUDENT

Derived classes – GRADUATE & POST GRADUATE

2. Inheritance

10.

Write a class CITY in Python with following specification :Code # Numberic valueName # String valuePop # Numberic value for PopulationKM # Numberic valueDensity # Numberic value for Population DensityMethods:CalDen ( ) # Method to calculate Density as Pop /KMRecord ( ) # Method to allow user to enter values Code, Name, Pop, KM and call CalDen ( ) methodSee ( ) # Method to display all the date members also display a message “Highly Populated Area” is the Density is more than 12000.

Answer»

class CITY:

def _init_ (self):

self. Code = 0

self. Name =” ”

self. Pop = 0

self. KM = 0

self. Density = 0

def CalDen (self):

self. Density = self. Pop/self. KM

def Record (self)

self: Code = input (“Enter Code”)

self.Name=raw_input(“Enter Name”)

self. Pop = input (“Enter population”)

self. KM = input (“Enter KM”)

CalDen (self) // or self.CalDen ( )

def See (self):

print Code, name, Pop, KM, Density

if self. Density > 12000:

print (“Highly Populated Area”)

# OR print (“Highly populated Area”)

Note : Accept self. _Cose to indicate private members

11.

Write a class DISTRICT in Python with following specification: Instance Attributes– Dcode # Numeric value– DName # String value– People # Numeric value for Population– Area # Numeric value– Density # Numeric value for Population Density

Answer»

Class DISTRICT ( ) :

def_init_(self, Dcode, DName, People, Area, Density):

self.Dcode = Dcode

self.DName = DName

self.People = People

self. Area = Area

self.Density = Density

Def display (self):

print (“District Code”, self.Dcode)

printf (“District Name”, self.Dname)

printf (“Population”, self.people)

printf (“Area”, self.Area)

printf (“Density”, self.Denstity)

12.

Answer the question (i) to (iv) based on the following:Class Shop (object):Class shop_(self) :self . no_of _employees = 0self. no_of _brands= 0def getSdate (self) :self. no_of_employees=input(“Number of employees”)self.no_of_brands=input(”Number of brands”)def showSdate (self) :Print self.no of employeesPrint self.no of brands class Brand (object) :def init_(self) :self.name = ” ”self.category=(“Mens”, “Womens”, “Kids”)self.avgprice=0, 0def getdate (self) :self.name = raw_input(“Enter Brand Name”)self.avgprice = input(”Enter Average Price”)def showdate (self) :Print self, namePrint self, categoryPrint self, avgpriceClass Mall (Brand, Shop) :def showdate (self) :self.no of shops = 0def getdate (self) :super (mall, self).getSdate ( ) # Statementsuper (mall, self).getdate ( ) # Statement 2self.no_of_shops=input (“Enter number of shops”)def showdata(self)print self.no_of_shopsprint self.no of brands # Blank 11. Which type of inheritance is demonstrated in the above code?2. Explain Statement 1 and 2.3. Name the methods that are overridden along with their class name.4. Fill Blank 1 with a statement to display variable category of class Brand.

Answer»

1. Multiple Inheritance

2. Statement 1 and 2 invoke the getSdate() function of class shop and getData() function of class Brand respectively.

3. getdata() method of class Brand is overridden. When object of class Mall is created.

M=Mall ( )

k.getdata ( )

getdate( ) methodof class Mall is invoked and not of class Brand is called.

4. print Brand ( ). category

13.

Rectify the error (if any) in the given statements.>> str=“Hello Python”>>> str[6]=‘S’

Answer»

str[6] = ‘S’ is incorrect ‘str’ object does not support item assignment.

str.replace(str[6],‘S’).

14.

Find the errors from the following code:if (a>b)print a:else if (a<b)print b:elseprint “both are equal”

Answer»

if (a>b) // missing colon

print a:

else if (a<b) // missing colon // should be elif

print b:

else // missing colon

print “both are equal"

15.

Find the errors from the following code: for i in 1 to 100: print i

Answer»

for i in range (1,100): 

print i

16.

Find the errors from the following code: T=[a,b,c] print T

Answer»

NameError: name ‘a’ is not defined. 

T=[‘a’,‘b’,‘c’]

17.

Find errors from the following codes:c=dict()n=input(Enter total number)i=1while i&lt;=n:a=raw_input(“enter place”)b=raw_input(“enter number”)c[a]=bi=i+1print “place”,“\t”,“number”for i in c:print i,“\t”,c[a[i]]

Answer»

c=dict()

n=input(‘‘Enter total number”)

i=1

while i<=n :

a=raw_input(“enter place”)

b=raw_inputf enter number”)

c[a]=b

i=i+1

print “place”,“\t”,“number”

for i in c:

print i,“\t”,c[i]

18.

Find the errors from the following code:i=10 ;while [i&lt;=n]:print ii+=10

Answer»

i=10

n=100

while (i<=n):

print i

i+=10

19.

Observe the following class definition and answer the question that follows :class info:ips=0def _str_(self): #Function 1return "Welcome to the Info Systems"def _init_(Self):self. _ Sstemdate= " "self. SystemTime = " "def getinput (self):self . Systemdate = raw_input ("enter data")self , SystemTime = raw_Input ("enter data")Info, incrips ()Estaiomethod # Statement 1def incrips ():Info, ips, "times"I = Info ()I. getinput ()Print I. SystemTimePrint I. _Systemdate # Statement 2(i). Write statement to invoke Function 1. (ii). On Executing the above code, Statement 2 is giving an error explain.

Answer»

(i). print I 

(ii). The statement 2 is giving an error because _Systemdate is a private variable and hence cannot to be printed outside the class.

20.

Define Webserver?

Answer»

Web server software is available as open source or licensed version in the market. A Web server is a Software that uses HTTP (Hypertext Transfer Protocol) to serve the files that form Web pages to users.

21.

Write short notes on PHP operator?

Answer»

Operator is a symbol which is used to perform mathematical and logical operations in the programing languages. 

Different types of operator in PHP are:

1. Arithmetic operators

2. Assignment operators 

3. Comparison operators 

4. Increment/Decrement operators, 

5. Logical operators, and 

6. String operators.

22.

A PHP script should start with ………… and end with ……(a) &lt; php &gt;(b) &lt; ? php ?&gt; (c) &lt; ? ? &gt; (d) &lt; ?php ? &gt;

Answer»

Correct Answer is: (d) < ?php ? >

23.

What does PHP files have a default file extension? (a) html (b) xml (c) .php (d) ph

Answer»

Correct Answer is: (c) .php

24.

Which of the following must be installed on your computer so as to mn PHP script? (a) Adobe (b) windows (c) Apache (d) IIS

Answer»

Correct Answer is: (c) Apache

25.

What does PHP stand for? (a) Personal Home Page (b) Hypertext Preprocessor (c) Pretext Hypertext Processor (d) Pre-processor Home Page

Answer»

(b) Hypertext Preprocessor

26.

Which of the following PHP statements Will output Hello World on the screen?(a) echo (“Hello World”) (b) print (“Hello World”) (c) printf (“Hello World”) (d) sprintf (“Hello World”)

Answer»

(a) echo (“Hello World”)

27.

Which statement will output $x on the screen? (a) echo “\$x” (b) echo “$$x” (c) echo “/$x” (d) echo “$x

Answer»

Correct Answer is: (a) echo “\$x”

28.

Which of the below symbols is a newline character? (a) \r (b) \n (c) /n (d) /r

Answer»

Correct Answer is: (b) \n

29.

The ………… is a high performance hardware machine it could run more than one application concurrently.

Answer»

The Server is a high performance hardware machine it could run more than one application concurrently.

30.

What are the common usages of PHP?

Answer»

1. It is very simple and lightweight open source server side scripting language. 

2. It can easily embed with HTML and other client side scripting languages like CSS (Cascading Style Sheets) and Java script.

3. It also creates dynamic and interaction Webpages in the red time Web development projects.

31.

What are the types scripting language?

Answer»

Web scripting languages are classified into two types, client side and server side scripting language. PHP is completely different from Client side scripting language like Java script. The PHP code entirely executes on Webserver which is installed in the remote machine.

32.

Difference between Client and Server?

Answer»

The server is a high performance hardware machine it could run more than one application concurrently. The client is a separate hardware machine which is connected with server in the network (Intemet/intranet). It could send the request and receive the response from the server hardware. The Server and client are also called as service provider and service requester respectively.

33.

Find the correct statement. 1) The embedded PHP file gets executed by the web client. 2) The embedded PHP file get executed in the web server.

Answer»

2) The embedded PHP file get executed in the web server.

34.

Give few examples of Web Browser?

Answer»

Internet Explorer 

UC Browser

Opera Google 

Chrome and 

Mozilla Firefox.

35.

The short open tags begins with ………and closes with …………

Answer»

The short open tags begins with <? and ?>.

36.

…………… is a software which is running in server hardware.

Answer»

webserver is a software which is running in server hardware.

37.

Statement I: Multi/Three tier Architecture is used for the server, accessed by client through more than one layer Interaction.Statement 2: The programmer could decide the count of business logic layers according to the software requirement.(a) I – True, II – False (b) I – False, II – True(c) I, II – Both True (d) I, II – Both False

Answer»

(c) I, II – Both True

38.

The ……… architecture is used for the server, accessed by client as two layer interactions.

Answer»

The two tier architecture is used for the server, accessed by client as two layer interactions.

39.

What is URL?

Answer»

URL: Uniform Resource Locator, the address of a specific Web page or file on the Internet. Eg. http://example.com

40.

CSS means (a) combined script style (b) cascading style sheets (c) calculated spreadsheet (d) consecutive script sheets

Answer»

(b) cascading style sheets

41.

What is Webserver?

Answer»

Web server software is available as open source or licensed version in the market. A Web server is a Software that uses HTTP (Hypertext Transfer Protocol) to serve the files that form Web pages to users.

42.

In how many ways you can embed PHP code in an HTML page?

Answer»

1. PHP script can be written in side of HTML code and save the file with extension of .php. The embedded PHP file get executed in the Webserver, the browser receives only the HTML and other client side files. 

2. Php files can also be embedded with css and js files. 

3. Using template engines like Smarty, DWOO, Mustache, Blade we can embed php files.

43.

Is PHP a case sensitive language?

Answer»

Yes, smaller case & uppercase letters are different in PHP.

44.

Define Client Server Architecture?

Answer»

The client server architecture introduces application sharing mechanism between two different hardware systems over the network (Intemet/intranet).

45.

PHP was invented by (a) Rasmus Lerdoof (b) Tim Berner’s Lee (c) Bob Frankston (d) Don Bricklin

Answer»

(a) Rasmus Lerdoof

46.

For short open tags, the admin has to enable settings in …………file? (a) init (b) php (c) initialise (d) php.ini

Answer»

For short open tags, the admin has to enable settings in php.ini file.

47.

Find the Correct one (i) PHP is an open source (ii) Apache tom cat supports PHP (iii) MS-ITS Supports PHP (a) Only (i) is true (b) (ii), (iii) – True (c) (i), (ii) – True (d) (i), (ii), (iii) – True

Answer»

(d) (i), (ii), (iii) – True

48.

What is the default port number taken by the software after installation? (a) 100 (b) 110 (c) 120 (d) 130

Answer»

Correct Answer is : (d) 130

49.

Explain the process of Webserver installation?

Answer»

Web server software that runs on server hardware, governs the server side scripting compilation into an intermediate byte-code that is then interpreted by the runtime engine.

Web server software is available as open source or licensed version in the market. Recent statistics of Web server usage depict that more than 130% Websites are running under the open source Web servers such as Tomcat Apache, Nginx etc.

 The following are the steps to install and configure Apache Httpd Web server and PHP module in windows server machine.

Step 1:

Go to Apache foundation Website and download the Httpd Webserver Software. 

https://httpd.apache.org/download.cgi

Step 2: 

After downloading .MSI file from Apache foundation Website, user launches the. MSI file and clicks next and next button to finish the installation on server machine. The software takes default port number 130 or 130130. Once the user finished, the Web server software is installed and configured on server hardware machine as a service.

Step 3: 

To test the installation of Apache Httpd Webserver, enter the following URL from your Web browser which is installed in your client machine.

https://localhost:130/ or https://localhost: 130130 The output page that says “Its works”

Step 4: 

Administrator user can start, stop and restart the Web server service at any time via windows Control panel. Once the services stops, the client machine will not receive the response message from server machine.

Step 5: 

Webserver’s configuration setting “httpd.conf” file is located in the conf directory under the apache installation directory. Edit this file and enable the PHP module to run PHP scripting language.

50.

Name the configuration setting file which is used to run PHP scripting language? (a) httpk.conf (b) httpd.conf (c) httpp.conf (d) httpdd.conf

Answer»

(b) httpd.conf