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

What are the types of cookies?

Cookies can be broadly classified into 2 types

1. Persistent cookies: Remain on the client computer, even after the browser is closed. You can configure how long the cookies remain using the expires property of the Http Cookie object.

2. Non-Persistent cookies: If you don't set the Expires property, then the cookie is called as a Non-Persistent cookie. Non-Persistent cookies only remain in memory until the browser is closed.

There two type of cookies ..
 Persistent cookies: cookies are stored on your computer hard disk. They stay on your hard disk and can be accessed by web servers until they are deleted or have expired. 
public void SetPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;
 cookie.Expires = Convert.ToDateTime(“12/12/2008”);

Non-persistent cookies: cookies are saved only while your web browser is running. They can be used by a web server only until you close your browser. They are not saved on your disk.
 public void SetNonPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;

What is Cache?

    Cache is the process performed by search engine crawler at a regular interval of time. It used to scan and take a snapshot of each page over world wide web as well as a store as a backup copy. Almost every search engine result page incorporates a cached link for every site. However, clicking on cached link show you the last Google cached version of that specific page rather than of current version. Also, you can directly prefix “cache:” with the desired URL to view it cached version

Page caching is another method which can help you to improve the load time of your web pages and thus optimize your site for the search engines. Page load time can significantly impact your user experience and your site’s ability into convert visitors into buyers or into leads. In fact, experiments at Google have revealed that just a half second’s difference in load times can cause up to a 20% reduction in web traffic. For this reason, the search engine companies are considering page load time to be an increasingly important factor for determining your site’s rank in the search results. This means you’ll need to take measure in reducing the size of your image files and your pages as a part of your SEO strategy.

What is a NullPointer Exception in and how to fix it

Null pointer exception means you are trying to access a member field or a function from an object which is null. for example you created a object of a class object name is "ClassAobj" and you want a variable value from class which is assign and initilize in that class now int a = ClassAobj.Number1; if "ClassAobj" is null then you can not access the value of Number1 . for fixing it ,either you have to initilize the class or you have to full if condition if(ClassAobj != null) { int a = ClassAobj.Number1; }

You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all.

Like anything else, null gets passed around. If it is null in method "A", it could be that method "B" passed a null to method "A".

The rest of this article goes into more detail and shows mistakes that many programmers often make which can lead to a NullReferenceException.

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.

What is Bandwidth?

    Every line has an upper limit and a lower limit on the frequency of signals it can carry. This limited range is called the bandwidth.

Internet bandwidth connects the world to the web. Let’s explore how bandwidth affects Internet speed, and how it’s measured.

Bandwidth refers to how much data per unit of time a network connection can handle. Bigger bandwidths allow greater data to flow through them.

Error opening a .txt file in C++

do it in following way
var fileStream = new FileStream(@"c:\file.txt", FileMode.Open, FileAccess.Read);
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
    string line;
    while ((line = streamReader.ReadLine()) != null)
        // process the line

How do you create a Persistent Cookie?

You create a persistent cookie the same way as session cookies except that you set the Expires property to a Date in the future which will store the Cookie to the client computer hard drive.

//Code to create a UserName Persistent Cookie that lives for 10 days
HttpCookie CookieObject = new HttpCookie("UserName", "David");
CookieObject.Expires = DateTime.Now.AddDays(10);

//Code to read the Cookie created above

Cookies have an expiration date implicitly or explicitly set which controls how long they last (subject to the user agent actually enforcing it). A cookie may persist only for the duration of the session (or an even shorter period).

If a cookie is valid, it will be passed along with the HTTP request to the domain that it originated from. Only the domain that set the cookie can read the cookie (though there are ways to exploit this, such as cross-site scripting).

  • If you want a cookie to expire at a specific time, set an expiration date on it using the client or server-side language of your choice.

  • If you want the cookie to expire when the session ends, don't set an expiration date.

What is Java Virtual Machine and how it is considered in context of Java’s platform independent feature?

When Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by Java Virtual Machine (JVM) on whichever platform it is being run.

Platform independency is one of the key aspect that Java provides and the question you have asked is a very common and basic one. I'm trying to explain it below. Hope it will help.

Explanation :

The java compiler compiles a java program and converts it into bytecode because of which a java program can run on wide variety of platforms.

Java Virtual Machine(JVM) is a Java run time system. It is platform dependent i.e its implementation differs from platform to platform. It provides the runtime environment in which java bytecode can be executed.

In order to run a java program on different platforms, only we need to implement platform specific JVMs and these all will execute the same byte code.This is the feature due to which java is considered as platform independent.

Explanation :

The java compiler compiles a java program and converts it into bytecode because of which a java program can run on wide variety of platforms. 

Java Virtual Machine(JVM) is a Java run time systemIt is platform dependent i.e its implementation differs from platform to platform. It provides the runtime environment in which java bytecode can be executed.

In order to run a java program on different platforms, only we need to implement platform specific JVMs and these all will execute the same byte code.This is the feature due to which java is considered as platform independent.

debugging error "Could not find prelaunch task 'null' "

Have you installed angularJS via npm? May be this is because of invalid JSON or task name missing in json file

The error occurs because Visual Studio Code cannot find any task in the tasks.json with the taskName value set to 'build'.

The preLaunchTask property of the launch.json file defines the task that should be executed before the script is launched. From the question, Visual Studio Code has been configured to run the task build before launching the script:

preLaunchTask: 'build'

But there's no task named 'build' in the tasks.json file.

To fix this, you should change the value of the preLaunchTask property to 'exe', which is the build task that has been defined in the tasks.json file.

What are the Selectors in Protractor ?

Select / Locate an element with protractor

Protractor Selectors / Locators are key components that user must take time to learn and master. This article will show you some examples of various selectors.

Protractor Selectors allow you to find elements within your page, Selectors are passed to the “element” function. Then “element” function will locate and return the selector.

Element(by.<Selector>);  // <Selector> is a placeholder, pl. see below list of various selectors.

CSS based Selectors:

CSS is the lifeline of any web page to add various design attributes, like layout, color, formatting, etc.,

<div class = “cssClass” id =”idOfTheElement”>

                Var s1 = element(by.css(‘.cssClass’)); or $('.some-class')

                Var s2 = element(by.css(‘#idOfTheElement’)); or $('#some-id');

                Var s3 = element(by.css(‘div’)); or  $(‘div’);

                Var s4 = $('tag-name');

                Var s5 = $('[ng-message=required]');

                Var s6 = $('#parent #child');

                Var s7 = $('ul li');

                Var s8 = $('ul li').first();

                Var s9 = $('ul li').last();

                Var s10 = $('ul li').get(index);


Button and Link Selectors:

Button Selectors:

<button> buttonText </button>

Var button1 = element(by.buttonText(‘buttonText’);

Link Selectors:

                <a href=”#”> link text </a>

                Var link = element(by.linkText(‘link text));

Some other interesting ones:

Then we get the more interesting ones:

  • element(by.model('data'));
  • element(by.repeater('cat in pets'));
  • element(by.options('c for c in colors'))
  • element(by.binding('value'));
  • element(by.buttonText('Save'));
  • element(by.partialButtonText('Save'));
  • element(by.cssContainingText('.pet', 'Dog'));
  • element(by.deepCss('span'));
That looks like jQuery syntax but it is not, it's part of Protractor. That's why .children is throwing an error because we're not actually using jQuery. $ is a shorthanded version of element(by.css()) i.e. $('my-css'); is the exact same as element(by.css('my-css')); They also have $$ which is the same as element.all(by.css()) Despite the lack of documentation, it does not have to be used for chaining to find child elements. i.e. using Julie's protractor demo (I modified the example): describe('Protractor Demo App', function() { it('read the header', function() { browser.get(''); $('h3').getText().then(function (val) { console.log(val); }); }); }); That prints out the title of the h3 element that I located. The $ and $$ are simply a shorthand for css selectors.

A locator in Protractor is used to perform action on HTML dom elements. The most common and best locators used in Protractor are css, id, model and binding. For example commonly used locators are: