Showing posts with label Interview Questions and Answers. Show all posts
Showing posts with label Interview Questions and Answers. Show all posts

Monday 21 June 2021

Kafka Interview Questions and Answers

Kafka Interview Questions and Answers

Question: What is Apache Kafka?
Apache Kafka is a open source framework written in Scala and Java which is used for distributed streaming platform.


Question: What are components of Kafka?
  1. Producer –Producers are responsible for sending the data to Kafka topic.
  2. Consumer –Consumers are subscribers to a topic and also reads and processes from the topic.
  3. Topic –It is name of Group where producer send the messages and consumer receive the messages.
  4. Brokers – We use broker to manage storage of messages in the topic .
  5. ZooKeeper - ZooKeeper is used to coordinate the brokers/cluster topology.



Question: Explain the role of the offset.
There is a sequential ID number given to the messages in the partitions that called offset.
It is used identify each message in the partition uniquely.


Question: What is a Consumer Group?
Kafka consumer group consists of one or more consumers that jointly consume a set of subscribed topics.


Question: What is the role of the ZooKeeper?
Apache Kafka is a distributed system is built to use Zookeeper.
Zookeeper’s main role here is to coordinate the brokers/cluster topology.
It also uses to recover from previously committed offset if any node fails because it works as periodically commit offset.



Question: What is Partition in Kafka?
In every Kafka broker, there are few partitions available, and each partition in Kafka can be either a leader or a replica of a topic. 



Question: What are advantage of kafka?
  1. High-throughput
  2. Low Latency
  3. Fault-Tolerant
  4. Durability
  5. Scalability


Question: What are main APIs of Kafka?

  1. Producer API
  2. Consumer API
  3. Streams API
  4. Connector API


Question: What are consumers?

Kafka Consumer subscribes to a topic, and also reads and processes messages from the topic. 



Question: Explain the concept of Leader and Follower?
There is one server which acts as the Leader, and Other servers plays the role as a Followers. 



Question: What ensures load balancing of the server in Kafka?
Main role of the Leader is to perform the task of all read and write requests for the partition, whereas Followers passively replicate the leader. At the time of Leader failing, one of the Followers takeover the role of the Leader. 



Question: Why are Replications critical in Kafka?
Replications make sure that published messages are not lost and can be consumed in the event of any machine error, program error or frequent software upgrades. 


Question: In the Producer, when does QueueFullException occur?
Kafka Producer attempts to send messages at a pace that the Broker cannot handle at that time QueueFullException typically occurs. 



Question: What is the purpose of retention period in Kafka cluster
Retention period retains all the published records within the Kafka cluster but It doesn’t check whether they have been consumed or not. We can also update the Retention period through configuration. 


Question: What is Maximum size of a message that can be received by the Kafka?
1000000 bytes 


Question: Explain Multi-tenancy?
We can enable the Multi-tenancy is enabled, We can easily deploy Kafka as a multi-tenant solution. However, by configuring which topics can produce or consume data 


Question: What is Streams API?
Streams API permits an application to act as a stream processor, and also consuming an input stream and producing an output stream to output topics. 



  Question: What is Connector API?
Connector API permits to run as well as build the reusable producers or consumers which connect Kafka topics to existing applications. 


Question: What are top companies which uses of Kafka?
Netflix
Mozilla
Oracle
etc


Sunday 28 March 2021

Graphql basic example with code snippet

Graphql basic example with code snippet
Question: What is GraphQL?
GraphQL is a query language for API, and it is server-side runtime for executing queries by using a type system you define in server.


Question: What is GraphQL used for?
Load data from a server to a client (API)


Is GraphQL a REST API?
GraphQL follows the same set of constraints as REST APIs, but it organizes data into a graph. GraphQL can speed up development and automation in comparison to REST API.


Is GraphQL frontend or backend?
Its neither frontend or backend. Its language to exchange the data between client and server.


Does Facebook use GraphQL?
Facebook used GraphQL since 2012.


Who uses GraphQL?
Facebook. Instagram. Shopify. Twitter. StackShare. Stack. The New York Times. Tokopedia. etc


GraphQL Example 1 with Node
var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    name: String,
    age: String,
  }
`);

var root = { name: () => 'My Name is Arun kumar.', age: ()=> '20 Year' };

graphql(schema, '{name}', root).then((response) => {
  console.log(response);
});



GraphQL Example 2 with Node
var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    name: String,
    age: String,
  }
`);

var root = { name: () => 'My Name is Arun kumar.', age: ()=> '20 Year' };

graphql(schema, '{name,age}', root).then((response) => {
  console.log(response);
});



GraphQL Example 3 with Node
var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    name: String,
    age: String,
    address: String,
  }
`);

var root = { name: () => 'My Name is Arun kumar.', age: ()=> '20 Year', address: ()=>'#238, Palm city, Sector 127, kharar'};

graphql(schema, '{name,age,address}', root).then((response) => {
  console.log(response);
});



GraphQL Example 4 with Node
const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');

const typeDefs = gql`
  type Query {
    hello: String,
    name: String,
    age: String,
    address: String,
    city: String,
  }
`;


const resolvers = {
  Query: {
    hello: () => 'Hello world!',
    name: () => 'My Name is Arun kumar.',
    age: ()=> '20 Year',
    address: ()=>' Sector 127, mohali',
    city:()=> 'kharar'
  },
};

const server = new ApolloServer({ typeDefs, resolvers });

const app = express();
server.applyMiddleware({ app });

app.listen({ port: 4000 }, () =>
  console.log('Now browse to http://localhost:4000' + server.graphqlPath)
);




GraphQL Example 5 with Node
var express = require('express');
var { graphqlHTTP } = require('express-graphql');
var { buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    hello: String,
    name: String,
    age: String,
    address: String,
    city: String,
  }
`);

var root = {
  hello: () => 'Hello world!',
  name: () => 'My Name is Arun kumar.',
  age: ()=> '20 Year',
  address: ()=>' My city, Sector 127',
  city:()=> 'kharar'
};

var app = express();
app.use('/graphql', graphqlHTTP({
  schema: schema,
  rootValue: root,
  graphiql: true,
}));
app.listen(4000, () => console.log('Now browse to localhost:4000/graphql'))





Thursday 23 July 2020

Python Interview Questions and Answers for Freshers

Python Interview Questions and Answers for Freshers

Question: What is current Stable version of Python?

Version: 3.5.1 Dated: 7 December 2015


Question: What is Filename extension of Python?
py, .pyc, .pyd, .pyo, pyw, .pyz


Question: What is offical website of Python?
www.python.org


Question: What is the difference between deep copy and shallow copy?
  1. Shallow copy is used when a new instance type gets created and it keeps the values that are copied.
    Deep copy is used to store the values that are already copied.
  2. Shallow copy is used to copy the reference pointers just like it copies the values.
  3. Shallow copy allows faster execution of the program whereas deep copy makes slow.

Question: How to use ternary operators?
[on_true] if [expression] else [on_false]
x, y = 25, 50
big = x if x < y else y



Question: What are different data-type in Python?
  1. Numbers
  2. Strings
  3. Strings
  4. List
  5. Dictionaries
  6. Sets



Question: What is module in python?
Module is set of related functionalities. Each python program file is a module, which imports other modules to use names they define using object.attribute notation.


Question: What is lambda in python?
lamda is a single expression anonymous function often used as inline function.


Question: How to validate Email Address in python?
re.search(r"[0-9a-zA-Z.]+@[a-zA-Z]+\.(com|co\.in)$","myemail@domain.com")



Question: What is pass in Python?
pass is no-operation Python statement and used to indicate nothing to be done.

Question: What is iterators?
iterators is used iterate over a group of elements, containers, like list


Question: What is slicing in Python?
Slicing is a mechanism to select a range of items from Sequence types like strings, list, tuple, etc.


Question: What is docstring in Python?
Python documentation string is a way of documenting Python modules, functions, classes. PEP 257 standardize the high-level structure of docstrings.


Question: Name few modules that are included in python by default?
  1. datetime
  2. re (regular expressions)
  3. string
  4. itertools
  5. ctypes
  6. email
  7. xml
  8. logging
  9. os
  10. subprocess


Question: What is list comprehension?
Creating a list by doing some operation over data that can be accessed using an iterator.
>>>[ord(i) for i in string.ascii_uppercase]
     [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]
 >>>



Question: What is map?
MAP executes the function given as the first argument on all the elements of the iterable given as the second argument.


Question: What is the difference between a tuple and a list?
A tuple is immutable i.e. can not be changed. It can be operated on only.
List is mutable. Changes can be done internally to it.


Question: How to Remove white spaces from string?
filter(lambda x: x != ' ', s)




Question: What are metaclasses in Python?
A metaclass is the class of a class.
A class defines how an instance of the class (i.e. object) behaves while a metaclass defines how a class behaves. A class is an instance of a metaclass.



Question: How do I check whether a file exists without exceptions?
os.path.isfile("/etc/password.txt");//true




Question: How to call an external command?
import subprocess
subprocess.run(["ls", "-l"])

Monday 21 October 2019

Symfony2 Interview Questions and Answers for Beginners

Symfony2 Interview Questions and Answers for Beginners

Question: What is Symfony?
Symfony is a PHP web application framework for MVC applications.


Question: Is Symfony Open Source?
Yes, It is Open Source.


Question: What is current Stable version of Symfony?
Version: 5.0.4, Dated: 31 Jan 2020


Question: What is offical website of Symfony?
symfony.com


Question: What is minimum PHP Version requirement for Symfony?
PHP 7.2.5


Question: What are benefits of Symfony?
  1. Fast development
  2. MVC Pattern
  3. Unlimited flexibility
  4. Expandable
  5. Stable and sustainable
  6. Ease of use.



Question: How to concatenate strings in twig?
{{ 'http://' ~ app.request.host }}



Question: How to get current route in Symfony 2?
$request = $this->container->get('request');
$currentRouteName = $request->get('_route');



Question: How to render a DateTime object in a Twig template?
{{ game.gameDate|date('Y-m-d') }}



Question: How to var_dump variables in twig templates?
{{ dump(user) }}



Question: How to get the request parameters in symfony2?
$name=$request->query->get('name');



Question: How to get list of all installed packages in composer?
composer global show


Saturday 5 October 2019

FuelPHP Interview Questions and Answers for Beginners

FuelPHP Interview Questions and Answers for Beginners

Question: What is FuelPHP?
FuelPHP is PHP Framework written in PHP, based on the HMVC pattern.


Question: Is FuelPHP Open Source?
Yes, It is Open Source.


Question: What is minimum PHP Version required for FulePHP?
PHP 5.4+


Question: Is FulePHP support Multilingual?
Yes, It support Multilingual.


Question: What is offical website of FulePHP?
fuelphp.com


Question: What are Key Features of FuelPHP?
  1. URL routing system
  2. RESTful implementation
  3. HMVC implementation
  4. Form Data validation
  5. ORM (Object Relational Mapper)
  6. Vulnerability protections like XSS, CSRF, SQL Protection and encode output.
  7. Caching System



Question: What is full form of HMVC?
Hierarchical-Model-View-Controller


Question: What is HMVC?
HMVC is an evolution of the MVC pattern.


Question: What are benefits of HMVC?
  1. Modularization
  2. Organization
  3. Reusability
  4. Extendibility



Question: How to get Query in FulePHP?
$userQueryToExecute = Model_Article::query()
        ->select('users')        
        ->where('blocked', '=', 1);

echo $userQueryToExecute->get_query();



Question: How to check that Redis server is running?
try
{
    $redis = \Redis::instance();    
}
catch(\RedisException $e)
{
    //here error will come
}



Question: How to use join with condition?
$queryObj = \Services\Model_Org::query()
->related('org')
->related('profile_image')->related( array(  'comments' => array(   'where' => array(    array('visible' , '=' , '0')   )
  ) ))
->where('rating','!=', 'null')
->order_by('rating','desc')
->get();