0% found this document useful (0 votes)
13 views

Angular Interview Qu

The document discusses Angular interview questions and their answers. Some key points covered are: - Angular is a TypeScript-based front-end framework developed by Google for building dynamic single-page web apps. - TypeScript adds static typing to JavaScript and is used to build Angular, leveraging features like classes, interfaces, and decorators. - Key Angular features include two-way data binding, dependency injection, modular development with NgModules, and a powerful CLI tool. - Structural directives like *ngIf and *ngFor conditionally render or repeat elements in the DOM template.

Uploaded by

NIVEDYA K V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Angular Interview Qu

The document discusses Angular interview questions and their answers. Some key points covered are: - Angular is a TypeScript-based front-end framework developed by Google for building dynamic single-page web apps. - TypeScript adds static typing to JavaScript and is used to build Angular, leveraging features like classes, interfaces, and decorators. - Key Angular features include two-way data binding, dependency injection, modular development with NgModules, and a powerful CLI tool. - Structural directives like *ngIf and *ngFor conditionally render or repeat elements in the DOM template.

Uploaded by

NIVEDYA K V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Certainly!

Here are some basic Angular interview questions:

What is Angular?

Angular is a TypeScript-based open-source front-end web application framework developed by


Google. It is widely used for building dynamic, single-page web applications (SPAs).

Explain TypeScript and its role in Angular.

TypeScript is a superset of JavaScript that adds static typing to the language. Angular is built using
TypeScript, and it leverages features such as classes, interfaces, and decorators to enable strong
typing and better tooling for large-scale applications.

What are the key features of Angular?

Some key features include two-way data binding, dependency injection, modular development,
declarative templates, and a powerful CLI (Command Line Interface).

Explain two-way data binding in Angular.

Two-way data binding is a synchronization mechanism between the model and the view. Changes in
the model automatically reflect in the view, and vice versa. This is often achieved using the
[(ngModel)] directive in Angular.

What is the purpose of decorators in Angular?

Decorators are used to enhance the behavior of classes in Angular. They are annotations that provide
metadata for the Angular compiler. For example, @Component is used to define a component, and
@Injectable is used for services.

What is dependency injection in Angular?

Dependency Injection (DI) is a design pattern used in Angular to create and manage dependencies
between different parts of an application. It helps in making components and services more modular
and reusable.

Explain the role of NgModule in Angular.

NgModule is a core building block of Angular applications. It is used to define a cohesive set of
components, directives, pipes, and services. Angular applications are modular, and each module can
have its own components, services, and more.
What is the difference between ngOnInit and constructor in Angular?

The constructor is a TypeScript feature and is used for class initialization. On the other hand,
ngOnInit is an Angular lifecycle hook that is called after the constructor and is specifically meant for
initialization code related to Angular.

What is the purpose of Angular CLI?

Angular CLI (Command Line Interface) is a powerful tool for initializing, developing, scaffolding, and
maintaining Angular applications. It provides commands to generate components, services, modules,
and more, making the development process more efficient.

Explain the concept of directives in Angular.

Directives in Angular are markers on a DOM element that tell Angular to attach a behavior to that
DOM element or transform the DOM element and its children. Examples include ngIf, ngFor, and
custom directives created by developers.

Certainly! *ngIf and *ngFor are structural directives in Angular that are used to conditionally render
or repeat elements in the DOM.

*ngIf

The *ngIf directive is used for conditional rendering. It evaluates an expression, and if the expression
is truthy, it renders the associated HTML template; otherwise, it removes the template from the
DOM.

Example:

html

Copy code

<div *ngIf="isUserLoggedIn">

Welcome, {{ username }}!

</div>

In this example, the div element is only rendered if the isUserLoggedIn expression is true.

*ngFor
The *ngFor directive is used for iterating over a collection (such as an array) and rendering a
template for each item in the collection.

Example:

html

Copy code

<ul>

<li *ngFor="let item of items">{{ item }}</li>

</ul>

In this example, the li element is repeated for each item in the items array.

Both *ngIf and *ngFor are prefixed with an asterisk (*) because they are structural directives. The
asterisk is a shorthand notation provided by Angular to make the code more readable.

Remember that *ngIf and *ngFor can be used together, allowing you to conditionally render and
repeat elements based on your application logic.

html

Copy code

<div *ngIf="showList">

<ul>

<li *ngFor="let item of items">{{ item }}</li>

</ul>

</div>

In this case, the list will only be rendered if showList is true, and it will iterate over the items array if
the condition is met.
Jsp-java server page

For making dynamic website on the server side.

Contain html tag and jsp tag

t is an advanced version of Servlet Technology

How JSP more advantageous than Servlet?


 They are easy to maintain.
 No recompilation or redeployment is required.
 Less coding is required in JSP.
 JSP has access to the entire API of JAVA.
 JSP are extended version of Servlet.

JDBC

Java database connectivity

API

JDBC(Java Database Connectivity) is a Java API, which is helpful in interaction with the
database to retrieve, manipulate and process the data using SQL. It will make use of JDBC
drivers for connecting with the database. By using JDBC, we can access tabular data stored
in various types of relational databases such as Oracle, MySQL, MS Access, etc.
What is ResultSet?

 The java.sql.ResultSet interface represents the database result set, which is obtained after the
execution of SQL query using Statement objects.
 Object of ResultSet maintains a cursor pointing to the current row of data in the result set.
Initially, the cursor is located before the first row. Then the cursor is moved to the next row by
using the next() method. The next() method can be used to iterate through the result set with
the help of a while loop. If there are no further rows, the next() method will return false.
 Example for the creation of ResultSet is given below:
ResultSet rs = con.executeQuery(sqlQuery).

Types of drivers

1,JDBC to ODBC driver

2, Native-API drive- The Native API driver uses the client-side libraries of the database. The driver
converts JDBC method calls into native calls of the database API. It is not written entirely in Java

3. ) Network Protocol drive- The Network Protocol driver uses middleware (application server)
that converts JDBC calls directly or indirectly into the vendor-specific database protocol. It is fully
written in Java. No client-side library is required

4) Thin driver The thin driver converts JDBC calls directly into the vendor-specific database
protocol. That is why it is known as a thin driver. It is fully written in Java language

Standard Steps followed for developing JDBC(JDBC4.X) Application


1. Load and register the Driver
2. Establish the Connection b/w Java application and database
3. Create a Statement Object
4. Send and execute the Query
5. Process the result from Result Set
6. Close the Connection

Checked Exceptions:
Checked exceptions are exceptions that are checked at compile-time.

They are subclasses of Exception but not subclasses of RuntimeException.

Examples of checked exceptions include IOException, SQLException, and


ClassNotFoundException.

Code that may throw a checked exception must be enclosed in a try-catch block or declared in
the method signature using the throws keyword. This ensures that the calling code handles the
exception or declares it in its own throws clause.

Unchecked Exceptions (RuntimeExceptions):

Unchecked exceptions are exceptions that are not checked at compile-time but are checked at
runtime.

They are subclasses of RuntimeException.

Examples of unchecked exceptions include NullPointerException,


ArrayIndexOutOfBoundsException, and ArithmeticException.

Unlike checked exceptions, there is no requirement to catch or declare unchecked exceptions


explicitly. However, it's still a good practice to handle them when possible.

You might also like