Friday, June 2, 2017

Java Experience latest Interview Quetions


1. Write the program to reverse the string without modify the special character?
2. Write the program to compare the object using comparable interface?
3. Write the program for singleton?
4. Explain concurrent packages?
5. Difference between @inject and @service annotation
6. Advantages of microservice and cassendra?
7. Write the program for executor library?
8. Whats inner join?
9. Write the program for rest controller?
10. Can we have multiple session factory in Hibernate?
11. Explain IOC container and dependency injection?
12. How many test cases you will write to test a method?

Tuesday, May 9, 2017

Difference between SED and AWK

sed is a stream editor. It works with streams of characters on a per-line basis. It has a primitive programming language that includes goto-style loops and simple conditionals (in addition to pattern matching and address matching). There are essentially only two "variables": pattern space and hold space. Readability of scripts can be difficult. Mathematical operations are extraordinarily awkward at best.
There are various versions of sed with different levels of support for command line options and language features.
awk is oriented toward delimited fields on a per-line basis. It has much more robust programming constructs including if/elsewhiledo/while and for (C-style and array iteration). There is complete support for variables and single-dimension associative arrays plus (IMO) kludgey multi-dimension arrays. Mathematical operations resemble those in C. It has printf and functions. The "K" in "AWK" stands for "Kernighan" as in "Kernighan and Ritchie" of the book "C Programming Language" fame (not to forget Aho and Weinberger). One could conceivably write a detector of academic plagiarism using awk.
GNU awk (gawk) has numerous extensions, including true multidimensional arrays in the latest version. There are other variations of awk including mawk and nawk.
Both programs use regular expressions for selecting and processing text.
I would tend to use sed where there are patterns in the text. For example, you could replace all the negative numbers in some text that are in the form "minus-sign followed by a sequence of digits" (e.g. "-231.45") with the "accountant's brackets" form (e.g. "(231.45)") using this (which has room for improvement):
sed 's/-\([0-9.]\+\)/(\1)/g' inputfile
I would use awk when the text looks more like rows and columns or, as awk refers to them "records" and "fields". If I was going to do a similar operation as above, but only on the third field in a simple comma delimited file I might do something like:
awk -F, 'BEGIN {OFS = ","} {gsub("-([0-9.]+)", "(" substr($3, 2) ")", $3); print}' inputfile
Of course those are just very simple examples that don't illustrate the full range of capabilities that each has to offer.

Tuesday, March 7, 2017

Happient mind Bangalore Telphonic interview Quetions

1.Restful API Client side code?
2.What is weaving?
3.Transaction management in Spring?
4.Spring and hibernate Integration?
5.Java 8 Features?
a.Lamda-Expression
b.Method References
c.Functional Interfaces
d.Streams
e.Optional Class
f.Date API
g.Base64

Friday, March 3, 2017

Angular JS 1 Tutorial

Angular Js 

Controller Responsibilities
--------------------------------
1.Fetching the right data from the server for the current UI
2 Deciding which parts of that data to show to the user
3 Presentation logic, such as how to display elements, which parts of the UI to show, how to style them, etc.
4 User interactions, such as what happens when a user clicks something or how a text input should be validated

Angular Js Life Cycle
-------------------------

1. The HTML is loaded. This triggers requests for all the scripts that are a part of it.
2. After the entire document has been loaded, AngularJS kicks in and looks for the ng-app directive.
3. When it finds the ng-app directive, it looks for and loads the module that is specified and attaches it to the element.
4. AngularJS then traverses the children DOM elements of the root element with the ng-app and starts looking for directives and bind statements.
5. Each time it hits an ng-controller or an ng-repeat directive, it creates what we call a scope in AngularJS. A scope is the context for that element. The scope dictates what each DOM element has access to in terms of functions, variables, and the like.
6. AngularJS then adds watchers and listeners on the variables that the HTML ac‐cesses, and keeps track of the current value of each of them. When that value changes, AngularJS updates the UI immediately.
7. Instead of polling or some other mechanism to check if the data has changed, An‐gularJS optimizes and checks for updates to the UI only on certain events, which can cause a change in the data or the model underneath. Examples of such events include XHR or server calls, page loads, and user interactions like click or type.


a.ng-class:
The ng-class directive is used to selectively apply and remove CSS classes from elements. There are multiple ways of using ng-class, and we will talk about what we feel is the most declarative and cleanest option. The ng-class directive can take strings or objects as values. If it is a string, it simply applies the CSS classes directly.
If it is an object (which we are returning from the function in the controller), An‐gularJS takes a look at each key of the object, and depending on whether the value for that key is true or false, applies or removes the CSS class.

b.ng-show
There are two directives in AngularJS that deal with hiding and showing HTML elements: ng-show and ng-hide. They inspect a variable and, depending on the truthiness of its value, show or hide elements in the UI, respectively. In this case,we say show the assignee span if note.assignee is true. AngularJS treats true,nonempty strings, nonzero numbers, and nonnull JS objects as truthy. So in this case, we get to see the assignee span if the note has an assignee.


Form States:
-----------
a.$invalid :AngularJS sets this state when any of the validations (required, ng-minlength, and others) mark any of the fields within the form as invalid.

b.$valid: The inverse of the previous state, which states that all the validations in the form are currently evaluating to correct.

c.$pristine: All forms in AngularJS start with this state. This allows you to figure out if a user has started typing in and modifying any of the form elements. Possible usage: disabling the reset button if a form is pristine.

d.$dirty :The inverse of $pristine, which states that the user made some changes (he can revert it, but the $dirty bit is set).

e.$error: This field on the form houses all the individual fields and the errors on each form element. We will talk more about this in the following section.

Built-in Angular Js Validators:
-------------------------------
a.required :As previously discussed, this ensures that the field is required, and the field is marked invalid until it is filled out.

b.ng-required: Unlike required, which marks a field as always required, the 

c.ng-required directive allows us to conditionally mark an input field as required based on a Boolean condition in the controller.

d.ng-minlength: We can set the minimum length of the value in the input field with this directive.

e.ng-maxlength: We can set the maximum length of the value in the input field with this directive.

f.ng-pattern: The validity of an input field can be checked against the regular expression pattern specified as part of this directive.
    type="email" :Text input with built-in email validation.
    type="number" :Text input with number validation. Can also have         additional attributes for min and max values of the number itself.
   type="date" :If the browser supports it, shows an HTML datepicker. Otherwise, defaults to a text input. The ngmodel that this binds to will be a date object. This expects the date to be in yyyy-mm-dd format (e.g.,
2009-10-24).
       type="url" :Text input with URL validation.

Common AngularJS Services
---------------------------
1.$window:
The $window service in AngularJS is nothing but a wrapper around the global win‐dow object. The sole reason for its existence is to avoid global state, especially in tests. Instead of directly working with the window object, we can ask for and work with $window. In the unit tests, the $window service can be easily mocked out (avail‐able for free with the AngularJS mocking library).
2.$location:
The $location service in AngularJS allows us to interact with the URL in the
browser bar, and get and manipulate its value. Any changes made to the $location service get reflected in the browser, and any changes in the browser are immediately captured in the $location service. The $location service has the following functions, which allow us to work with the URL:
a.absUrl
A getter that gives us the absolute URL in the browser (called $location.
absUrl()).
b.url
A getter and setter that gets or sets the URL. If we give it an argument, it will set the URL; otherwise, it will return the URL as a string.
c.path
Again, a getter and setter that sets the path of the URL. Automatically adds the forward slash at the beginning. So $location.path() would give us the current path of the application, and $location.path("/new") would set the pathto /new.
d.search
Sets or gets the search or query string of the current URL. Calling $location.search() without any arguments returns the search parameter as an object. Calling $location.search("test") removes the search parameter from the URL, and calling $location.search("test", "abc"); sets the search pa
rameter test to abc.
3.$http

Config function :
------------------
• The config function executes before the AngularJS app executes. So we can be assured that this executes before our controllers, services, and other functions.
• The config function follows the same Dependency Injection pattern, but gets providers injected in. In this case, we ask for the ItemServiceProvider.
• At this point, we can now call functions and set values that the provider exposes.
We are able to the call the disableDefaultItems function that we defined in the
provider.
• The config function could also set up URL endpoints, locale information, routingconfiguration for our application, and so on: things that need to be executed and initialized before our application starts.
• We can try changing the value of shouldHaveDefaults to true (this would come from the server or URL, or some other way usually) to see the effect it has on ourapplication.

Directives :
AngularJS directives are what controls the rendering of the HTML inside an AngularJS application. 

myapp = angular.module("myapp", []);

myapp.directive('div', function() {
    var directive = {};

    directive.restrict = 'E'; /* restrict this directive to elements */

    directive.template = "My first directive: {{textToInsert}}";

    return directive;
});

$watch()
The $scope.watch() function creates a watch of some variable. When you register a watch you pass two functions as parameters to the $watch() function:
  • A value function
  • A listener function
Here is an example:
$scope.$watch(function() {},
              function() {}
             );


Thursday, March 2, 2017

Spring Interview Quetions

1.     What is dependency injection and what are the advantages?
2.     What is an interface and what are the advantages of making use of them in Java?
3.     What is meant by “application-context” and how do you create one?
4.     What is the concept of a “container” and what is its lifecycle?
5.     Dependency injection using Java configuration
6.     Dependency injection in XML, using constructor or setter injection
7.     Dependency injection using annotations (@Component, @Autowired)
8.     Component scanning, Stereotypes and Meta-Annotations
9.     Scopes for Spring beans. What is the default?
10.   What is an initialization method and how is it declared in a Spring bean?
11.     What is a destroy method, how is it declared and when is it called?
12.    What is a BeanFactoryPostProcessor and what is it used for?
13.    What is a BeanPostProcessor and how is the difference to a
14.      BeanFactoryPostProcessor? What do they do? When are they called?
15.        Are beans lazily or eagerly instantiated by default? How do you alter this behavior?
16.    What does component-scanning do?
17.    What is the behavior of the annotation @Autowired with regards to field injection,
18.     constructor injection and method injection?
19.      How does the @Qualifier annotation complement the use of @Autowired?
20.      What is the role of the @PostConstruct and @PreDestroy annotations? When will                   they get called?
22.         What is a proxy object and what are the two different types of proxies Spring can
              create?
24.      What is the power of a proxy object and where are the disadvantages?
25.    What are the limitations of these proxies (per type)?
26.     How do you inject scalar/literal values into Spring beans?
27.     How are you going to create a new instance of an ApplicationContext?
28.    What is a prefix?
29.        What is the lifecycle on an ApplicationContext?
30.      What does the "@Bean annotation do?
31.     How are you going to create an ApplicationContext in an integration test or a JUnit
                       test?
33.     What do you have to do, if you would like to inject something into a private field?
34.      What are the advantages of JavaConfig? What are the limitations?
35.     What is the default bean id if you only use "@Bean"?
36.       Can you use @Bean together with @Profile?
37.     What is Spring Expression Language (SpEL for short)?
38.     What is the environment abstraction in Spring?
39.     What can you reference using SpEL?
40.        How do you configure a profile. What are possible use cases where they might be
                   useful?
42.       How many profiles can you have?
43.    How do you enable JSR-250 annotations like @PostConstruct?
44.     Why are you not allowed to annotate a final class with @Configuration
45.       Why must you have a default constructor in your @Configuration annotated class?
46.    Why are you not allowed to annotate final methods with @Bean?
47.     What is the preferred way to close an application context?
48.    How can you create a shared application context in a JUnit test?
49.   What does a static @Bean method do?
50.    What is a ProperyPlaceholderConfigurer used for?
51.   What is @Value used for?

52.   What is the difference between $ a

Sunday, February 26, 2017

Angular JS 1 Quetions


  • What's MVC architecture?
  • What's MVVM architecture?
  • What's two way binding?
  • What's ng-model?
  • What is $http?
  • What is ng-repeat?
  • What are $index$even$odd$first, and $last?
  • How would you filter a list via ng-repeat?
  • What's the difference between angular.module('app' , []) and angular.module('app')
  • What are directives (briefly)?
  • Why would you use ng-submit instead of ng-click in some cases?
  • What's Dependency Injection?
  • Do other frameworks use dependency injection (even if only for internal use)? Answer: yes (React,Ember)
  • How would you inject services and what are the different ways to do so?
  • What's jqLite?
  • How do you ensure Angular uses jQuery when including them both?
  • What are promises and how would you use them?
  • What's the difference between factory/provider/service/value/constant?
  • When would you use each one?
  • What are filters?
  • Why would you use ng-src, ng-bind, and ng-cloak?
  • What's the difference between ng-if and ng-show?
  • What phases are there in angular? Answer: config -> bootstrap -> run
  • Why would you use .config() and .run() phase?
  • What is ng-app and how does angular bootstrap?
  • When would you use $q.all()?
  • Where would you make your network calls controller, template, directive, or service and why? (where would you use $http)
  • Say that you are going to alert an error where would you put that alert from a network call? Service, controller, template and why? Answer
  • How would you dynamically filter a list with an ng-repeat? (clicking on different filters)
  • What's ng-messages and ng-message?
  • What's ng-style and ng-class?
  • How would you attach something to the header of every http call?
  • What is $scope.$on() and how would you use it?
  • What are $http interceptors?
  • What is "$locationChangeStart"?
  • What's html5Mode?
  • How do you turn off cache for a $http call?
  • What is the $templateCache?
  • How would you implement auth as in locking down certain parts of the app?
  • What's ui-router and why use it over ng-route?
  • What are states?
  • How do you resolve resources via state/route and how would you do so?
  • Given 3 nested states, how would you load the most nested one after the root state resolves while allowing the middle state to load asynchronously?
  • What types of directives are there? Angular: element, attribute, class (no one uses class)
  • What is $scope?
  • What is $rootScope?
  • What is "$destroy"?
  • What's one time binding?
  • When and where would you normally use .$watch()?
  • What's a stateful filter vs a stateless filter?
  • What are .$dirty.$pristine.$valid.$invalid, and .$submitted?
  • What's NgModelController?
  • What's FormController?
  • What's ng-model-options and why would you use it?
  • What are $validators and $asyncValidators?
  • What's the difference between scope$scope, and $rootScope?
  • What's the difference between controller and link directives?
  • How do you require a controller in a directive?
  • How do you require more than one controller in a directive?
  • What's an isolated scope?
  • For an isolate scope what are these symbols ?,@,=,&,* in relation to directives
  • What are compile/pre-link/post-link phase for directives?
  • What is $interpolate?
  • What is $compile?
  • What is $observe?
  • What's transclusion?
  • Why would you need transclusion?
  • What's bindToController: and controllerAs: syntax?
  • What are directives and what are components?
  • What's the difference between .$broadcast(), and .$emit()?
  • What are $timeout() and $interval() and how do you cancel them?
  • What's dirty checking?
  • Do other frameworks use dirty checking? Answer: yes (React,Polymer)
  • What is the .$digest() loop?
  • What's the difference between .$digest() and .$apply()?
  • What are $watchGroup and $watchCollection?
  • What are $eval$parse and $evalAsync?
  • What is $applyAsync?
  • What's a decorator in relation to angular's module system?
  • How would you filter a large list with ng-repeat to include data from the server and client?
  • How would you grab the $injector/$scope from the chrome console?
  • Why is there ng-form?
  • How would you dynamically create forms?
  • What's CSP and how does it relate to angular?
  • How do you structure your files for a large team/project?
  • How would you use a module loader/bundler such as browserify, webpack, or systemjs with angular?
  • How would you asynchronously load angular?
  • How would you inject server rendered data into client angular?
  • What's a document fragment?
  • What's the ShadowDOM?
  • What is needed for your angular web app to work with JavaScript disabled?
  • What is needed for your angular web app to be rendered on the server to be sent down to the client?
  • Generally speaking how would you paraphrase angular?
  • How would you progressively enhance your RESTful app with a pub/sub?
  • How would you structure your app if you only had a realtime (pub/sub) API (no REST)?
  • What are the different ways to architect your angular app?
  • What are the pros and cons of each design?
  • What are some anti patterns developers tend to fall into while using angular?
  • What are the problems currently facing angular1?
  • Explain how Angular 2 is solving all of the problems from 1.x
  • Demonstrate a few ways to migrate an Angular 1 app to Angular 2
  • What's the difference between MVC, MVVM, MVP(SC), MVP(PV), PM, and how does it compare to Flux/Redux architecture?
  • How are dependencies handled when testing Angualar controllers and services?
  • How is $scope injected when testing Angular controllers?
  • What is the purpose of wrapping core Angular providers and services in double underscores? ex: _$rootScope_?
  • Describe the necessary steps to test the Angular $http service
  • How would you test an $http request to a third party API such as Youtube?
  • How would you test the data being returned from the API request?
  • What frameworks, languages and tools are available for testing in Angular?
  • How is $scope used when testing Angular controlers?
  • Explain what $httpBackend and $httpBackend.flush are used for
  • Explain what angular.mock is used for