All java c# asp.net .net servlet jdbc c sqlserver android ado.net javascript php wcf clearcase angularjs 2

What is difference between config() and run() method in AngularJS? which runs first ?

AngularJS   .Config() Method - configuration gets executed during the configuration phase. We can inject providers and constants into configuration block. This block is used to inject module wise configuration settings to prevent accidental instantiation of services before they have been fully configured.

AngularJS  .Run method – Run method is executed after the configuration method. we can inject instances and constants in run method. The run method is a great place to put event handlers that need to be executed at the root level for the application. For example, authentication handlers.

Configuration():  get executed during the provider registrations and configuration phase. Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured.

Run(): get executed after the injector is created and are used to kickstart the application. Only instances and constants can be injected into run blocks. This is to prevent further system configuration during application run time.Run blocks are the closest thing in AngularJS to the main method. It is executed after all of the services have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.

why you used JavaScript? Can it use for both client side and server side validation purpose?

Javascript is a client side scripting, which runs in the browser. Even AJAX runs in the browser and is also a client 
side one, which actually is nothing but Javascript. In AJAX javascript is used to communicate with server side 
components or post values to a JSP / ASP or any web page or any services which can be referred by URL.

JavaScript is a platform-independent,event-driven, interpreted client-side scripting and programming language. 

Javascript (ECMA script) when executed in the browser context makes it client side, if you are using it for creating API's etc with nodeJS you get to use it on the server side 

Client-side validation just avoids the client from going "but I filled this all in and it didn't tell me anything!". It's not actually mandatory, and in reality, client-side validation is a very new thing (read: 5 years old or less). In practice, all it does is prevent your client (with JS enabled) to know whether the form is okay before reloading a page. If AJAX is in the game, it is different - it allows you to save bandwidth as well as to provide user with feedback before submission. Finally, if you're building strictly client-side, peer-to-peer exchange apps (think games), you'll want client-side validation to keep the clients from cheating.

Server-side validation is also crucial due to the fact that client-side validation can be completely bypassed by turning off JavaScript. In a way, JS-driven validation is a convenience and an aesthetic/cosmetic improvement and should not be relied upon. Furthermore, it is trivial to edit the source of a page locally in order to disable or bypass even the most complex of JS validation.

What could a user do if you do not server-side validate? Anything, depending on how you use their data. You could be allowing users to drop entire databases (or worse, leak them), modify anything they like (or worse, read anything they like. Directory traversal flaws are extremely common entrance points for naughty people), and elevate their privileges at will. Do you want to run this risk? Not validating user input is like trusting people and not installing locks on your house.

The main use of Javascript is that it allows you to make things happen in the user's browser without sending messages back and forth to the server. There are a variety of reasons why you might want to do this.

For example, sending a message to the server and getting a reply is a relatively long process: it is almost always a noticable time lag, and can take many seconds. Doing something directly in the browser can be much faster. So if, for example, you want to give the user an "invalid data" message of some sort, it can be much faster if it comes from Javascript.

In the same vein, with Javascript you can validate field-by-field rather than waiting until the user has completely filled out the screen and clicked a submit button. For example, suppose you present the user with a screen where he's supposed to enter transaction dates and monetary amounts. The user enters a whole screen full of these -- maybe 20 or 30 transactions -- and then clicks submit. If the user attempts to type dates in a format that you don't recognize, say typing day/month/year when you expected year-month-day, then with Javascript you could give him an error on the first unrecognizable date. With a round trip to the server, he'd have typed in a whole screen-full of invalid dates before you tell him he's doing it wrong.

What is closures in JavaScript, can someone explain them in detail

JavaScript variables can belong to the local or global scope.

Private variables can be made possible with closures.

JavaScript Closures
Remember self-invoking functions? What does this function do

<!DOCTYPE html>
<html>
<body>

<p>Counting with a local variable.</p>

<button type="button" onclick="myFunction()">Count!</button>

<p id="demo">0</p>

<script>
var add = (function () {
    var counter = 0;
    return function () {return counter += 1;}
})();

function myFunction(){
    document.getElementById("demo").innerHTML = add();
}
</script>

</body>
</html>

Whenever you see the function keyword within another function, the inner function has access to variables in the outer function.

function foo(x) {
  var tmp = 3;

  function bar(y) {
    console.log(x + y + (++tmp)); // will log 16
  }

  bar(10);
}

foo(2);

What is jQuery $.proxy() Method, what is the use ? can anyone explain this

The $.proxy method takes an existing function and returns a new one with a particular context. This method is often used for attaching events to an element where the context is pointing back to a different object. $(selector).proxy(function,context)

This method is most useful for attaching event handlers to an element where the context is pointing back to a different object

What are JavaScript types?

Broadly, the Javascript is of Two type. they are 

  1. Clint side JavaScript
  2. Server side JavaScript

"Data Types" in programming languages refer to the type of value a language recognizes.
Javascript recognizes 5 types of data:

  • Numbers (1, 2, 3, 59.45 etc.)
  • Booleans (true,false)
  • Strings ("Hello")
  • null (no value)
  • undefined (type of value is not defined)

 JavaScript types:

Data TypeDescription
       String                     represents sequence of characters e.g. "hello"  
      Numberrepresents numeric values e.g. 100
     Booleanrepresents boolean value either false or true
     Undefinedrepresents undefined value
      Nullrepresents null i.e. no value at all

The non-primitive data types are as follows:

Data TypeDescription
Objectrepresents instance through which we can access members
Arrayrepresents group of similar values
RegExprepresents regular expression

JavaScript types are commonly two types. Client and server side

How do I compare strings in Java? Please provide some examples

use the equals() method of String class

if( string1.equals(string2) )

{

// do something
}

else{
// do something

}

There are three ways to compare string in java:

  1. By equals() method
  2. By = = operator
  3. By compareTo() method
public static void main(String []args){ String s1 = "Hello"; String s2 = "Hello"; String s3 = new String ("hello"); System.out.println(s1.equals(s2)); true System.out.println(s2.equals(s3)); false } System.out.println(s1 == s2); true System.out.println(s2 == s3); false == will work some of the time,as java has a String pool, where it tries to reuse memory references of commonly used strings. But == compares that objects are equal, not the values... so .equals() is the proper use you want to use.

What is the relationship between JavaScript and ECMAScript?

JavaScript is officially standardized as ECMAScript by European Computer Manufacturers Association (ECMA). it is internationally oriented body embraced by Microsoft and holding the standards for C#, CLI and Open XML.

Microsoft's version of JavaScript is JScript and it is mostly compatible with ECMAScript v.3. The intersection
between these three variations of the same language is at:

  • # JavaScript 1.5 (without DOM)
  • # JScript as supported by IE6 (still the most widely used browser)
  • # ECMAScript ver. 3

The largest difference between JavaScript and JScript is actually interpreter/runtime related. IE6 was known for some notorious performance issues related to its non-generational garbage collector when operating on large object trees.

Javascript is the original name when the language was developed by Netscape. JScript is Microsoft's name of their own implementation. ECMAScript is the name of the language standard developed by ECMA, from the original Javascript implementation.

What are the advantages of AngularJS?

Yes, it is pretty common question about the AngularJS, I found some of them :

  • Data Binding - AngularJS provides a powerful data binding mechanism to bind data to HTML elements by using scope. One-Way Databinding : Very important with respective of performance, which helps us to minimize the $Digest calls. Two-way Binding : seamlessly exchanges the data between, view and controllers.
  • Customize & Extensible - Customize and extensible as per your requirement. You can create your own custom components like directives, services etc.
  • Code Reusability - AngularJS allows you to write code which can be reused. For example, custom directive which you can reuse.
  • Support – AngularJS is mature community to help you. It has widely support over the internet. Also, AngularJS is supported by Google which gives it an advantage. There is a very active google group for AngularJS, lot of people post AngularJS questions and get answers.
  • Browser Compatibility - AngularJS is based on JavaScript which makes it easier to integrate with any other JavaScript library and executable on browsers like IE, Opera, FF, Safari, Chrome etc.
  • Unit & E2E Testing- AngularJS is designed to be testable so that you can test your app components as easy as possible. It has dependency injection at its core, which makes it easy to test.
  • AngularJS provides capability to create Single Page Application in a very clean and maintainable way.

  • AngularJS provides data binding capability to HTML thus giving user a rich and responsive experience.

  • AngularJS code is unit testable.

  • AngularJS uses dependency injection and make use of separation of concerns.

  • AngularJS provides capability to create Single Page Application in a very clean and maintainable way.

  • AngularJS provides data binding capability to HTML thus giving user a rich and responsive experience.

  • AngularJS code is unit testable.

  • AngularJS uses dependency injection and make use of separation of concerns.

  • AngularJS provides reusable components.

  • With AngularJS, developer writes less code and gets more functionality.

Enumerate the differences between Java and JavaScript?

Java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for the different intent. Java is an object - oriented programming (OOPS) or structured programming languages like C++ or C whereas JavaScript is a client-side scripting language and it is said to be unstructured programming.
The Key differences between Java and JavaScript: Java is an OOP programming language while Java Script is an OOP scripting language. Java creates applications that run in a virtual machine or browser while JavaScript code is run on a browser only. Java code needs to be compiled while JavaScript code are all in text.

Key differences between Java and JavaScript:

  • Java is an OOP programming language while Java Script is an OOP scripting language.
  • Java creates applications that run in a virtual machine or browser while JavaScript code is run on a browser only.
  • Java code needs to be compiled while JavaScript code are all in text.
  • They require different plug-ins.

Which Javascript file is responsible for validation at the client side?

WebUIValidation.js javascript file is mainly used for validation by the validators at client side. This file will be installed at "aspnet_client" at IIS directory.

Struts Validator Framework provides an easy-to-use mechanism for performing client-side validation. It's very useful to validate some fields on the client-side before sending the data to the server for processing. By this way we can ensure that the data send to the server is valid. Performing validations on the client-side save the user a round trip time to the server.

For each validation routine defined in the validation-rules.xml file Struts provides an optional JavaScript code that can run on the client-side to perform the same validation that takes place on the server side.