Friday, January 18, 2019

Python Interview Questions & Answers

Python Interview Questions and Answers

Python is a massively growing  programming language in current times. There are some basic questions which is asked while anybody is going for an interview. I would like to share some of the questions which are widely asked for an interview.

1. What is Python?
Ans: Python is an object oriented , interpreted , high level programming language created by Guido van Rossum and first released in 1991. It is enriched with high level built in data structures and combined with dynamic typing and dynamic binding. More importantly it has very easy to learn syntax and therefore it enhances the readability and cost of maintenance. Python supports modularity and code re-use in a very efficient manner and therefore it is extensible and flexible as well.

2. How will you define function in Python?
Ans: A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.

 a. Function block begins with def keyword.
 b. In function declaration tag there will be colon at the end. (i.e def calculate(): )
 c. There won't be any parenthesis in the start/end of the function.
 d. Return type is not required while declaring the function.

3. What kind of typed of language Python is? Explain why?
Ans. Python is dynamically typed language. It means you need not to declare the variable type while developing the code. In time of execution it will be decided depending on the value you have assigned to your variable.

Example:
a=7
b="Python"

In time of execution variable a will be considered as Integer and b as String

4. How will you define variable in Python?
Ans: We need to type the variable name and assign the value into it. As python is dynamically typed language, it will interpret the variable type at run time.

5. What are the different loops used in Python?
Ans: Like other programming languages Python also has certain conditional blocks. Please find below the loops which is used in Python.
if,else, elif, for , while etc.
Example:

if a=1:
 println("Python")
elif a=2:
 println("Java")
else:
 println("C++")


6. What kind of various String formatting are possible in Python?
 Ans: String formatting is required to generate the output with more accuracy.
%s - String (or any object with a string representation, like numbers)

%d - Integers

%f - Floating point numbers

%.<number of digits>f - Floating point numbers with a fixed amount of digits to the right of the dot.

%x/%X - Integers in hex representation (lowercase/uppercase)


7. Tell some built in function which is massively used for Scripting?
Ans: There are lot of functions which is used widely. Here are few of them.
Python abs() returns absolute value of a number
Python dict() Creates a Dictionary
Python dir() Tries to Return Attributes of Object
Python divmod() Returns a Tuple of Quotient and Remainder
Python enumerate() Returns an Enumerate Object
Python eval() Runs Python Code Within Program
Python exec() Executes Dynamically Created Program
Python filter() constructs iterator from elements which are true
Python float() returns floating point number from number, string
Python format() returns formatted representation of a value

8. How to compile and run Python script?
Ans: Please find the below steps.
Windows User:
1.First you have to install python
2. Then set path variable
(My Computer > Properties > Advanced System Settings > Environment Variables >
Create a new variable PYTHONPATH and add values C:\Python\Lib;C:\Python\DLLs;C:\Python\Lib\lib-tk)
3.After that write your python program and save
4.Create a sample python program that name "hello.py"
5.Open cmd.exe
6.Then goto the path that you saved your "hello.py" file,
and then type python hello.py and press enter key.


9. Difference between Python and Shell.
Ans: Python and Shell both are scripting languages. But Python has some additional features which makes it useful for building diversified application. Here are some differences between this two:

i. There are external libraries in Python , by importing those we can easily make any functionality with lesser code and complexity than Shell.
ii. In Python there are concept of list,dictionary,Tuple so building a data structure is very easy in Python but in case of Shell there are no such concept is there which makes it less useful.
iii. Python can be useful for web development by using it's stock of libraries but in case of Shell it is not possible.

10. What is Pandas in Python?
Ans: Pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python. Additionally, it has the broader goal of becoming the most powerful and flexible open source data analysis / manipulation tool available in any language.

11. What is Cython?
Ans: Cython is a optimistic static compiler for both Python and extended Cython programming language. The Cython is superset of Pyton language and additionally support C language and declaring C types on variable and class attributes.This allows compiler to generate very efficient C code from Cython language.
For details please go to the following link:
http://docs.cython.org/en/latest/

12. Explain OOPS Feature in Python?
Ans: Python is an object-oriented programming language besides it's scripting nature. It allows us to develop applications using an Object Oriented approach. In Python, we can easily create and use classes and objects.

Major principles of object-oriented programming system are given below.

Object
Class
Method
Inheritance
Polymorphism
Data Abstraction
Encapsulation

13. What is dictionary in Python?
Ans: Dictionary is special data type in Python. Those who are familiar with Map/HashMap in Java it could be easier to understand for them. Dictionary is actually combination of key-value pair. It is an un-ordered collection of data. So, insertion order can not be maintained. But accessing/updating the data operation is too fast.

14. Difference between Tuple and List in Python?
Ans: Tuple and List both are two important and frequently use data type in Python. But there are few basic differences between these two.
1. Tuple is immutable but List is mutable.
2. In Tuple insertion order can not be maintained but in case List insertion order is maintained properly.
3. Tuple is heterogeneous data structure but List is a homogeneous data structure.

15. Tell some package which you have used in your program.

scapy,matplotlib,kivy,nltk,keras,SQLAlchemy etc.

16. What is anonymous function in Python and explain the use case.
Ans: In Python, anonymous function is a function that is defined without a name.
While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambda keyword.
Lambda functions can have any number of arguments but only one expression. The expression is evaluated and returned. Lambda functions can be used wherever function objects are required.

double = lambda x: x * 2

# Output: 10
print(double(5))

Monday, December 31, 2018

ASP.NET MVC Interview Questions -- Part 3

ASP.NET MVC Interview Questions -- Part 3

  1. What are Validation Annotations?
  2. What is Data Annotation Validator Attributes in MVC?
  3. What is Validation Summary in MVC?
  4. What is the use of remote validation in MVC?
  5. Server Side Validation in MVC?
  6. How to make sure Client Validation is enabled in ASP.Net MVC?
  7. How to use Jquery Plugins in ASP.Net MVC validation?
  8. In Server how to check whether model has error or not in ASP.Net MVC?
  9. How can we create Custom Error Page in MVC?
  10. What is GET and POST Actions Types?
  11. How can we determine action invoked from HTTP GET or HTTP POST?
  12. Explain Test Driven Development (TDD) ?
  13. Why to use Html.Partial in MVC?
  14. What is Html.RenderPartial?
  15. What is RouteConfig.cs in MVC?
  16. What are Scaffold templates in MVC?
  17. Explain the concept of MVC Scaffolding?
  18. Explain the types of Scaffoldings.
  19. Can a view be shared across multiple controllers? If Yes, How we can do that?
  20. What are the components required to create a route in MVC?
  21. Why to use “{resource}.axd/{*pathInfo}” in routing in MVC?
  22. What are the two instances where routing is not implemented or required?
  23. What is Route Constraints in MVC?
  24. Can we add constraints to the route? If yes, explain how we can do it?
  25. What are the two ways to add constraints to a route?
  26. What are the possible Razor view extensions?
  27. What are the Main Razor Syntax Rules?
  28. What is PartialView in MVC?
  29. How do you create a partial view and consume it?
  30. What is the difference between View and Partial View?
  31. How we can add CSS in MVC?
  32. What is the use .Glimpse in MVC?
  33. What are the differences between Partial View and Display Template and Edit Templates in ASP.Net MVC?
  34. Explain the need of display mode in MVC.
  35. What is Representational State Transfer (REST) mean?
  36. Explain the tools used for unit testing in ASP.Net MVC?
  37. What are the different Approach in MVC using Entity Framework?
  38. What is Database First Approach in MVC using Entity Framework?
  39. What are the Folders in MVC application solutions?
  40. What are the methods of handling an Error in MVC?
  41. How can maintain session in MVC?
                 Click Here for Part 1            Click Here for Part 2

ASP.NET MVC Interview Questions -- Part 2

ASP.NET MVC Interview Questions -- Part 2

  1. Explain Bundle.Config in MVC.
  2. What is Route in MVC?
  3. Where is the route mapping code written?
  4. What is Default Route in MVC?
  5. How route table has been created in ASP.NET MVC?
  6. Which are the important namespaces used in MVC?
  7. In which assembly is the MVC framework is defined?
  8. What is ViewData?
  9. What is the difference between ViewBag and ViewData in MVC?
  10. What is the difference between Temp data, View, and View Bag?
  11. How can we pass the data From Controller To View In MVC?
  12. Explain using hyperlink how you can navigate from one view to other view?
  13. Explain TempData in MVC?
  14. What is Area in ASP.Net MVC?
  15. How we can register the Area in ASP.Net MVC?
  16. What are HTML Helpers in MVC?
  17. What is the difference between “HTML.TextBox” and “HTML.TextBoxFor”?
  18. What are AJAX Helpers in MVC?
  19. What are the Exception filters in MVC?
  20. How we can handle the exception at controller level in ASP.Net MVC?
  21. How can we do exception handling in MVC?
  22. What are the options can be configured in AJAX helpers?
  23. What is Layout in MVC?
  24. Explain Sections is MVC?
  25. Explain RenderSection in MVC?
  26. Explain RenderBody and RenderPage in MVC?
  27. What is ViewStart Page in MVC?
  28. Explain the methods used to render the views in MVC?
  29. What are the sub types of ActionResult?
  30. What is the difference between "ActionResult" and "ViewResult" ?
  31. What are Non Action methods in MVC?
  32. How to change the action name in MVC?
  33. Explain Peek method in Tempdata in ASP.Net MVC?
  34. Explain Keep method in Tempdata in ASP.Net MVC?
  35. How do you implement Forms authentication in MVC?
  36. What are Code Blocks in Views?
  37. What is Output Caching in MVC?
  38. What are the locations for Output Caching?
  39. How we can multiple submit buttons in ASP.Net MVC?
  40. What is the “HelperPage.IsAjax” Property?
  41. How we can call a JavaScript function on the change of a Dropdown List in MVC?
                 Click Here for Part 1            Click Here for Part 3

ASP.NET MVC Interview Questions -- Part 1

ASP.NET MVC Interview Questions -- Part 1

The ASP.NET MVC is a web application framework developed by Microsoft, which implements the model–view–controller (MVC) pattern.

Based on ASP.NET, ASP.NET MVC allows software developers to build a web application as a composition of three roles: Model, View and Controller. The MVC model defines web applications with 3 logic layers:

  • Model (business layer)
  • View (display layer)
  • Controller (input control)

  1. What is ASP.NET MVC?
  2. Explain Model, Controller and View in MVC?
  3. Define Controller in MVC?
  4. Explain Model in MVC?
  5. Explain View in MVC?
  6. Explain the page life cycle of MVC?
  7. Explain MVC application life cycle?
  8. Explain what are the steps for the execution of an MVC project?
  9. What are the advantages of MVC?
  10. What is Separation of Concerns in ASP.NET MVC?
  11. What is Razor View Engine?
  12. What is the meaning of Unobtrusive JavaScript?
  13. What is the use of ViewModel in MVC?
  14. Mention the advantages and disadvantages of MVC model?
  15. What you mean by Routing in MVC?
  16. What are the three segments for routing important?
  17. What are Actions in MVC?
  18. What is the importance of NonActionAttribute?
  19. How we can invoke child actions in ASP.Net MVC?
  20. What are Filters in MVC?
  21. Explain the role of "ActionFilters" in MVC?
  22. Mention some action filters which are used regularly in ASP.Net MVC?
  23. List out different return types of a controller action method?
  24. What are Action Filters in MVC?
  25. What "beforFilter()","beforeRender" and "afterFilter" functions do in Controller?
  26. What is the need of Action Filters in ASP.Net MVC?
  27. Explain the role of components Presentation, Abstraction and Control in MVC?
  28. What is Attribute Routing in MVC?
  29. How to enable Attribute Routing?
  30. Explain JSON Binding?
  31. What are Model Binders in ASP.Net MVC?
  32. Can I set the unlimited length for "maxJsonLength" property in config?
  33. What are child actions in ASP.Net MVC?
  34. What is JsonResultType in MVC?
  35. How to return the JSON from action method in ASP.Net MVC?
  36. How can I return string result from Action in ASP.Net MVC?
  37. Explain Dependency Resolution?
  38. What is Dependency Injection in ASP.Net MVC?
  39. Explain the advantages of Dependency Injection (DI) in ASP.Net MVC?
  40. Can I use Razor code in Javascript in ASP.Net MVC?
  41. What is Bundling and Minification in MVC?
                 Click Here for Part 2            Click Here for Part 3

Monday, December 17, 2018

Spark Interview Questions

Spark Interview Questions:

Spark is a framework which is heavily used in Hadoop(Hadoop 2.0/Yarn) in order to execute Analytical, Streaming , Machine Learning process in a very efficient way. I would like to take you through some of the questions those are frequently asked in any interview.

Spark:

1. What is Spark.
2. Explain higher level architecture of Spark.
3. What is Driver &Executor and explain the difference between them
4. What is DAG
5. How do you trace your failed job through DAG.
6. What is Persistence. Name difference level of Persistence.
7. Why do we use Repartittion & Coalesce
8. What is RDD,Dataframe & Dataset and explain difference between them
9. How to see partition after loading a input file in Spark.
10. How do we load/store any Hive table in Spark
11. How to read JSON,CSV file in Spark.
12. What is Spark Streaming.
13. Name some properties which you have set in your project
14. How could a Hive UDF be used in Spark session
15. Explain some troubleshooting in Spark
16. What is Stage,Job,Tasks in Spark
17. Difference between GroupByKey and ReduceByKey
18. What is executor memory and explain how did you set them in your project
19.Name some Spark functions which have been used in your project
20. What is Spark UDF and write the signature of the same. 

Friday, December 14, 2018

C# Interview Questions -- Part 3

C# Interview Questions -- Part 3

71. Explain Get and Set Accessor properties?
72. What is a Thread? What is Multithreading?
73. Name some properties of Thread Class.
74. What are the different states of a Thread?
75. What are Async and Await?
76. What is a Deadlock?
77. Explain Lock, Monitors, and Mutex Object in Threading.
78. What is a Race Condition?
79. What is Thread Pooling?
80. What is Serialization?
81. What are the types of Serialization?
82. What is an XSD file?
83. What are the different types of constructors in C#?
84. Is overriding of a function possible in the same class?
85. What is a collection?
86. What is the lock statement in C#?
87. What are the difference between IEnumerable and IQueryable.
88. What is the difference between early binding and late binding in C#?
89. Which are the access modifiers available in C#?
90. What is Hashtable?
91. What is Garbage Collection?
92. Explain sealed class.
93. Give an example of using sealed class in C#.
94. What are the two different types of errors in C#.
95. Do we get error while executing “finally” block in C#.
96. Mention the assembly name where System namespace lies in C#.
97. What are value types in C#?
98. What are reference types in C#?
99. Explain access modifier “protected internal” in C#.
100. What you mean by inner exception in C#.
101. Can we use delegates for asynchronous method calls in C#?
102. Why to use “Nullable Coalescing Operator” (??) in C#?
103. What is enum in C#?

                Click Here for Part 1            Click Here for Part 2

C# Interview Questions -- Part 2

C# Interview Questions -- Part 2

36. What are delegates?    
37. What is the base class in  net from which all the classes are derived from?   
38. What is the difference between method overriding and method overloading?    
39. What are the different ways a method can be overloaded?    
40. Why can't you specify the accessibility modifier for methods inside the interface?    
41. How can we set class to be inherited, but prevent the method from being over-ridden?    
42. What happens if the inherited interfaces have conflicting method names?    
43. What is the difference between a Struct and a Class?    
44. How to use nullable types in  Net?   
45. How we can create an array with non-default values?    
46. What is difference between is and as operators in c#?    
47. What's a multicast delegate?    
48. What are indexers in C#  NET?   
49. What is difference between the "throw" and "throw ex" in  NET?   
50. What are C# attributes and its significance?    
51. How to retrive attribute information at runtime?    
52. How to implement singleton design pattern in C#?    
53. What is the difference between directcast and ctype?    
54. Is C# code is managed or unmanaged code?
55. What are C# I/O Classes? What are the commonly used I/O Classes?
56. What is a Destructor in C#?
57. What is the difference between Continue and Break Statement?
58. What is the difference between finally and finalize block?
59  What is an Escape Sequence? Name some String escape sequences in C#.
60. What are Regular expressions? Search a string using regular expressions?
61. What are the basic String Operations? Explain.
62. What is Parsing? How to Parse a Date Time String?
63. What are Events?
64. How to use Delegates with Events?
65. What are the different types of Delegates?
66. What do Generic Delegates mean?
67. Explain Publishers and Subscribers in Events.
68. What are Synchronous and Asynchronous operations?
69. What is Reflection in C#?
70. What is a Generic Class?

                 Click Here for Part 1            Click Here for Part 3