Skip to main content

Posts

Showing posts from May 12, 2017

Q.what is the meaning of AfterReturning Advice: ?

RealTime Example of AfterReturning Advice:- ==================================== Q.what is the meaning of AfterReturning Advice: ? Simple way after executing my targetClass business logic it return some data which will validate/check to achive flexibility inside my cross cutting logic / aspect class and that will be executed automatically for the purpose of specially validating Example:- ======== suppose m a regular customer in pantaloon and as per my transaction record pantaloons offer me an payBack card which is for ex golden card ok....now i purchase 80000$ from pantaloon and after billing my product they gave me a printing bill.... Based on my bill Amount and my membership cardType they will decided as per there business benifit policy how much discount offer will give to me which will decided at runtime means after purchase....... see if they directly announce or display same policy in his shop then which will be completely tightly coupled coz every day discount will not
import java.util.*; class RailwayInfo{ public static boolean isGoodTrain(String name, int avgSpeed,int totalDistance, boolean isPassengerHappy, int noOfStation,String[] typeOfCoach){ int ratio=totalDistance/noOfStation; List data=Arrays.asList(typeOfCoach); if(name.length()>1 && (name.endsWith("Mail")||name.endsWith("Express")) &&(avgSpeed>70) && (totalDistance>700) && ((name.contains("Mail")&& ratio==50)|| (name.contains("Express") && ratio==100)) && (isPassengerHappy==true) &&  ((totalDistance>=1000 && totalDistance<=1500 )&& (data.contains("3AC"))) || (totalDistance>=1500 && data.contains("2AC"))){ System.out.println("Valid.."); return true; } return false; } public static void main(String[] args){ System.out.println(isGoodTrain("VishskMail",1000,1000,true,20,new String[]{"2AC","3A

Difference between jar and Api ?

Difference between jar and Api ? Api -Application programming interface. = = = = = = = = = = = = = = = = = = = = = = = Read this sentence slowly u will get idea Api is nothing it is always partial who contain only interface or Abstract class. ..which I can't directly access. So to access that api in market several 3rd party vender r present. Ex:-Apache,IBM etc.. Connection is an interface given by sun people for establish connection in jdbc Api. ..think can u directly access it ? ❌ Connection con= new Connection (); U can't do this coz Connection is an interface so we can't instantiate it that's why we need implementation. ...For accessing that interface. .who will provide us implementation ? Implementation provide by 3rd party vender so. ...that's why one vender provide us an Class DriverManager nd inside this class there is one Static Factory method i.e getConnection() when u call that static method with class name u will get to accessing connectio
In the season of joy I present my sincere wishes and kind thoughts. May the kind of New Year outshine all the rest. Wishing you all the blessings of a beautiful season...... Run this one nd see the magic import java.util.*; import java.text.*; class PrintMessage { public static void display(String msg) throws Exception{ for(int i=0;i<=msg.length()-1;i++){ char displayMessage=msg.charAt(i); Thread.sleep(400); System.out.print(displayMessage); } } public static void wisher(String name){ DateFormat df=DateFormat.getDateInstance(); String date=df.format(new Date()); System.out.println("wishes by "+name+":on date "+date); } public static void main(String[] args)throws Exception{ wisher("Basant"); display(" Advance Happy New Year 2018 to all Amarjit Kharga _Java_Gyan_Mantra group members 😃 "); } }

The real difference between Process and Thread in Java ?

The real difference between Process and Thread in Java ? One of the common question from programming interviews is, what is the difference between a Thread and a Process? Well, the main difference between them is that a Process is a program which is executing some code and a thread is an independent path of execution inside the process. A process can have more than one thread for doing independent task e.g. a thread for reading data from disk, a thread for processing that  data and another thread for sending that data over the network. This technique to improve throughput and better utilize CPU power is also known as multi-threading. Technically, most significant difference between thread is address space and context switching. All thread from a process share same address space but a process has their own address space. Similarly, context switching between process is more expensive than context switching between threads.

webservices architecture.

webservices architecture...try to zoom and see it....

Some basic interview question on collection. .......

Some basic interview question on collection. ....... Collection :- =========== If u want to represent group of object's as a single entity then we have to use Collection Collection Framework :- = = = = = = = = = = = = = = = It defines several class and interfaces which can be used to define collections 1.What is the difference between collection and map ? Ans:- Collection represents a group of individual objects Map represents a group of key value pairs 2 . collection and Collections ? Ans:- Collection is an interface Collections is a utility class which contain multiple method for collection Collections class defines several utility methods for collection objects like Collections.sort ( al ); 3 . what is the main purpose of generics Ans:- The main objective of generics are to provide type safety under to resolve type casting problems 4. difference between list and set ? 5 . what is cursor and how many cursor are available in java? 6 . what is the need of concurent

Spring mvc control flow :-(see below digram. ......step by step)

Spring mvc control flow :-(see below digram. ......step by step) = = = = = = = = = = = = = = = = = = = To make webapp 👉 1 .First From browser u forward request to servlet (Dispatcher Servlet) to handel it.. 👉 2.Dispatcher Servlet here act as a controller. Who only manage the request processing. ..so it rcv the request and then forward request to HandlerMapping 👉 3.Handler mapping is framework provide class..Normally in mvc there r several controller Bean so HandlerMapping helps to search appropriate controller Bean based on request url to perform business operation 👉 4.and 5 After finding controller Bean it process some operation and return MAV object ..to Dispatcher Servlet M:-model A:-and V:-view 👉 6 . Now after processing business operation response will be generated and it should be display on browser otherwise how enduser know about response. ..so to find appropriate view representer..Dispatcher Servlet call again ViewResolver. .which helps to find appropriate js

Drop down list fst u have to store in Database.

Drop down list fst u have to store in Database. . Then create ur own customize cache and write logic for read data from table. Which will reduce the trip between ur application to Database. ......and ur cache should be singleton so to manage it an d for flush proposal u have to use CacheManager... As per ur question what you want I just gave here theoritical explanation... Just wait and let complete the class then I will provide you sample code 

What is final, finally and finalize ?

Interview prospective hot question What is final, finally and finalize ? 👉 final:- = = = =  final is a keyword/modifier. It applicable for class, variable and method. .. If you declare ur class with final keyword then no one can extends ur class. .. no IS-A(inheritance) relationship. ....no one can reuse ur class. ... If you declare ur variable as final then it act as constant. We can't do any modifications on that perticular variable. If you declare ur method a final then subclass can't override it. .. 👉 finally:- = = = = = finally is a block. Used in Exception Handling it always associate with try block. ..Normally it is used to clean up activities. ..means inside it all statement always be execute eventhough ur code is terminate in middle or in any abnormal condition. ... Note:- There some situation in which ur finally block also not executed. . 1. If System.exit(0) placed inside try /Catch block then ur finally block will not be executed 2 . another case if

Why main method syntax is given by sun people like

Why main method syntax is given by sun people like public static void main ( String [ ] args ) ================================ 👉 Public :-it declare as public coz this method is called by whome jvm itself. So jvm can call it from any where. .. 👉 static:-coz main method no way related with any instance so without createing any instance jvm can call it .That's why it make it as static 👉 Void:- void means no return type coz suppose ur method return some value to jvm then jvm what will do with this value. So it's return type is void 👉 main:-this is simple name by naming convention nd only this name is configured in jvm that's why jvm always search that similar name i.e (main)... 👉 (String[] args):- max used datatype in application is String so it is consider as command line argument. ..

What is System.out.println() ?..

What is System.out.println() ?.. Shortly. ... 👉 System:- system is a class which present inside java.lang pkg 👉 Out:- out is a static variable present in System class of type PrintStream ✔Ex:- class System { private static PrintStream out; } 👉 println():-println() is a method which is present in side PrintStream class ✔Ex:- class PrintStream{ Void print(){} void println(){} }

What are the basic that we should have aware on it before developing Jax-Rpc api based webservices ?

What are the basic that we should have aware on it before developing Jax-Rpc api based webservices ? 📡 ♨ Normally there r 2 type of webservices 1.jax-rpc 2.jax-ws Here I am disussing about only jax-rpc based webservices where we always develop provider. ... Pre requisite for developing Jax-Rpc based webservices :-:-:-:-:-:-:-:-:- @Type of approaches:- = = = = = = = = = = = = = = 1 . Contact First approach 2 . Contract Last approach 👉 Fst we have to discuss above 2 approach Contract First and Contract Last:- = = = = = = = = = = = = = = = = = = = = Always webservices means we have to consider 2 actor I.e Consumer and provider .There is a middle person who always stay as a contract between consumer and provider which is called as WSDL..... 👉 So if you Fst develop WSDL before developing provider it is called as Contract first. . 👉 If you develop fst provider then u develop WSDL it is called as Contract Last approach @Type of endpoint :- = = = = = = = = = = = = = 1 . ser

Why jax-B is given by Sun people ?

Why jax-B is given by Sun people ? Fst we have to know the awareness about jax-B. ....jax-B is an Api which support Xml binding technology. .means convert Xml to Object. And object to Xml. ... Before sun people interduce that api in industry there are multiple 3rd party vender already provided this technology. Exactly same as Xml binding technology. Like ✔XmlBeans ✔Javoulution ✔XmlThunder etc...There r near about 30+ 3rd party libreries present. To work with Xml binding technology So after long day sun people know the importance of Xml binding technology which is reduces the burden of developer nd reduces the cost of projects development in integration layer then in in jdk 1.5 sun people provide indirect support for it. .nd complete direct support they provide in 1.6 Now we have to think why Jax-B :- = = = = = = = = = = = = = = = = = = = = In case of webservices there r 2 actor 1.Consumer 2.Provider Always consumer need to interact with provider. ..but consumers send data to

Why jax-p api is given by sun people ?

Why jax-p api is given by sun people ? 👉 in simple way jax-p is an Api which is basically used for to read the content of Xml. ......but now we have to know why jax-p is came even though there is any other way is available to read the content of Xml. .. 🌎 Think how many way we can read the content of Xml ? 1 . By using FileInputStream... (But here problem is as a programmer we have to write the complicated logic to read Xml by FileInputStream..For multiple times and code will be duplicate also. ..so which is not a good approach. ) 2 . By using 3rd party libreries Means Xml4j DOM4j etc... (But here is again we face problem. Here we can avoid code duplication but problem is code is not reusablity means Suppose I developed my project based on Xml4j .but Xml4j have certain limitation I.e it can't read Xml if that Xml contain more than 1lkh element. .so to avoid this I want to use DOM4j insted of Xml4j. ...so in that case we have to rewrite the code again. ..... Which affec

How many way we can get database connection and which one is best approaches and why ??

How many way we can get database connection and which one is best approaches and why ?? Basiacally there r two way to get:- connection from DB . 👉 1.DriverManager 👉 2.DataSource  but in real time 2nd one is preferable.coz in case of DriverManager we have to remember all the connection property to get connection from Db.nd it is also not reusablity nature. Suppose u create one connection obj then u can perform one time operation any other class can't reuse that connection again. . so to over come it we use DataSource(I) to get connection .from DataBase.in nd case by using this DataResource we achive connection pool concept.in this case we need not to set connection properties and we no need to take headach for creating object to get connection that work is done/set by ADMIN in DataSource Implementation class object nd these property r bind with JNDI(java naming directory interface) registry. we just lookup from registry to get that object nd make connection with DB.... .. 🌍 .

What is the difference between SAX and DOM ?

What is the difference between SAX and DOM ? 👌 Common questions in case of xml:- = = = = = = = = = = = = = = = = = = = Both are used for read the content of Xml .both are universal methodlogy independent on language we can say it is interprorable nature but based on requirements we have to use it 👍 SAX:-(simple access for Xml api) = = = = = = = = = = = = = = = = = = SAX is used for read content of Xml in sequencial order one after another so .And this all concept about sax based on event base processing model 👉 1 . which is consume less memory 👉 2 . performance wise very fast... Fst parse point ur top part of Xml then read one by one. But if you want to just read Xml then it's better approach to use . 👉 3.sax is read only api 👉 4 . reading order is sequencial manner one by one 👍 DOM:-(Document object model ) = = = = = = = = = = = = = = = = = = It is also used for read content of Xml but it is read in orbitary manner. It working based on hierarchy principle. .means i