Posts

Showing posts from September, 2019

Node instalation

Image
Install Node JS ----------------------------------------------------------------------------------------------- Download Node js ------------------------------------------------------------------------- *)Go to the following link https://nodejs.org/en/ choose 1st green button (10.16.3 LTS) and download. Then install that software after download. click next and go ahead Now you have to work in command line to install the command line interface ------------------------------------------------------------------------------------------------------ (reference :-     https://cli.angular.io/    ) The above website contains the steps to run in command line. for windows :- *) open the cmd (command prompt) and open it as administrator. Then follow the steps. *)(Sudo is used only for Mac/Linux before every command if  you are using windows then no sudo is required.) Run    npm install -g npm    Updating the C...

Dipendency injection in spring example

1 .create a java project.In source folder create a package.Inside  the package create the classes.Inside the source folder directly create an xml file named applicationContext.xml. 2.Load the spring jar files in the java build path. --- code for setter injection in spring ----------------------------------- Employee.java ------------------------------------------- package com.sandeep.SpringPractice; public class Employee { private String name; private int id; private String location; /*public Employee() { System.out.println("Inside default constructor"); } public Employee(String name,int id,String location) { this.name=name; this.id=id; this.location=location; }*/ public void setName(String name) { this.name = name; } public void setId(int id) { this.id = id; } public void setLocation(String location) { this.location = location; } public String toString() { return ("name :"+name+...

Use of toString() method

When we print an object, internally the toString() method is called internally. toString() namaste print the hash code of the object. So if you want to print your own message instead of hashcode, just override toString() method and give your own implementation. 

Core Concept of java object

Where java object is created ? ---------------------------------------------------- In Java, all objects are dynamically allocated on Heap. In Java, when we only declare a variable of a class type, only a reference is created (memory is not allocated for the object). To allocate memory to an object, we must use new(). So the object is always allocated memory on heap .

Core Concept on Java polymorphism

Image
Following are some important points for method overriding and static methods in Java. 1)  For class (or static) meth polymorphism ods, the method according to the type of reference is called, not according to the object being referred, which means method call is decided at compile time. 2)  For instance (or non-static) methods, the method is called according to the type of object being referred, not according to the type of reference, which means method calls is decided at run time. 3)  An instance method cannot override a static method, and a static method cannot hide an instance method. For example, the following program has two compiler errors. 4)  In a subclass (or Derived Class), we can overload the methods inherited from the superclass. Such overloaded methods neither hide nor override the superclass methods — they are new methods, unique to the subclass. 1. Can we override the static method? No, a static method cannot be overridden. It can be ...