Author Archives: devender kumar

About devender kumar

java/j2EE developer


Interview tips

Hi in this post i am going to tell few points that will surly help you if you are going for an interview. This points are as important as your knowledge in the interview. So here are the points.

Reach on time

When ever you go for interview make sure you reach 10 -15 minutes earlier . If you are travelling long distance for face to face interview then schedule your visit so that you can reach on time.  My success percentage in interview is 100% when i reach at the interview venue 15 minutes earlier. It give me time to relax.  Also it gives positive impression of you. It shows that you are punctual.

Research about company

This point is very very important. This point usually comes into play generally when you have reached to managerial round or HR round. If you are going in product based organization then know about the products of company. I am not saying read the whole information. At Least have some information so that you can say yes i know about your company and you can ask question about the company based on the information. This question help when the interview say Do you have any Question for Me.

Have knowledge of everything you mentioned in resume

Because of this point i got rejected sometimes.  make sure your resume do not have skills in which you are not good. For example if you are going for Java developer interview and you have prepared for it. Now you have mentioned java script html css and jquery etc in your resume. There are good chances that interviewer may ask you question from java script html css and jquery if the interview have knowledges. Do not increase size of resume by putting un- necessary skills in your resume.

Know your technical projects

As the part of preparation, you should focus on two or three technical projects that you should deeply master. Ideally most recent projects. Most common questions from your project could be following

  1. Challenging part of each project. This question is most frequently in technical rounds or managerial rounds. They want to know how you think and your problem solving skills is assessed based on your answer. There can be few more question  based on your answer. So have deep knowledge of your 2-3 projects.
  2. Your role in the projects.
  3. For the projects be able to talk about challenges, mistakes, technical decisions, choice of technology.
  4. Work flow of each project. This question is very very important and is asked almost in every interview.
  5. For more than 3 year experience person project architecture can be asked.

Be polite

Please be polite with the interviewer. No one going to buy your attitude in the interview. I have seen few related  videos where they show attitude matters. But the reality is different. In the interview you need to be polite. Do not show arrogant behavior. Event if you are not agree with any point decline it politely or ask your question politely. Do not sound arrogant.

Some companies where there are multiple rounds of interview you may not feel comfortable in the initials rounds, because questions may be below your level or you are not expecting according to your experience level. So do not judge about the interview process.  This has happened with me. In the initials two rounds they ask me questions that i thought below my level. Even any fresher can answer those questions. After those two round next few rounds went extremely well. More challenging questions come up. I was very happy by the end. So keep patience.

Be specific, limit details

When a candidate blabber about the problem, it is hard for the interviewer to understand who is not well versed with the subject or project. Stay light on details and state only key points.  You can always offer the interviewer the opportunity to drill in further by saying i can go into more details if you would like.

This is all in the post. Hope it will help you in your next interview. Keep learning. Stay blessed. Happy New Year.


Polymorphism in java with example and clear understanding

Hi in this post we will see what is polymorphism in java. I think this is one of favorite interview question as well. Let me start with the definition of polymorphism then we will see example.

polymorphism definition:

property of object to take many different form depending on the type of reference used to access the object.(do not worry it will be clear when we will see example). To be more precise Java object may be accesses using a reference with the same type as the object, a reference that is superclass of the object or a reference of interface that the object implement directly or through a superclass.

Regardless of the type of reference you have for the object in memory, the object itself does not change.

The type of object determines which properties exist within the object in memory.

The type of reference to the object determine which methods and variable are accessible.

Now lets see example. This example is very simple and properly commented. Still if you have any question please do write down your views in comments.



Hope this example clear your understanding of polymorphism. If you have any doubt or any suggestion please write down to me in comments.

Salesforce Important interview questions

Hi in this post of salesforce article i am going to share salesforce interview questions that my friend Ankit Jain has shared. Some of questions are answered some need to be answered. Hope these questions may help you. Please do share if you have more questions in salesforce and java.

1. Name three Governor Limits .
50,000 records limit soql
100 soql
150 dml fire
2. When do you use a before vs. after trigger?
Before until we don’t need id field
3. What’s the maximum batch size in a single trigger execution?
4. What are the differences between 15 and 18 digit record IDs?
Case sensitive
5. Provide an example of when a Custom Setting would be used during
6. When should you build solutions declaratively instead of with code?
Wherever possible
7. Give an example of a standard object that’s also junction object.
8. Describe a use case when you’d control permissions through each of the
9. – Profiles
10. – Roles
11.– Permission Sets
12. – Sharing Rules
13. When should an org consider using Record Types?
14. What are some use cases for using the Schema class?
Check for access Schema.isAccessable,Creatabe,getting describeresult
15. A trigger is running multiple times during a single save event in an org.
How can this be prevented?
Use Trigger.isExecute
16. Why is it necessary for most sales teams to use both Leads and
17. What is the System.assert method and when is it commonly used?
Compare 2 values
18. What are the differences between SOQL and SOSL?
Multi object search ,single object soql seacrh 10000 records total,sosl search
19. Order the following events after a record is saved:
20. – Validation rules are run
21. – Workflows are executed
22. – “Before” triggers are executed
23. – “After” triggers are executed
24. What is Trigger.old and when do you normally use it?
Deletion,account merge
25. When should you use a lookup instead of a masterdetail
When parent is not manditory and you dont need rollup sumary
26. What are the advantages of using Batch Apex instead of a trigger?
27. What are the pros and cons when using a Workflow Rule Field Update
vs. a Formula Field?
28. What are the differences between a Map and a List?
Map key values
29. What are the advantages of using Batch Apex instead of a trigger?
30. Describe a use case for Static Resources.
Easy caching
31. Provide an example of when a Matrix report would be used. How about
a Joined report?
32. A group of users must be prevented from updating a custom field.
What’s the most secure method of preventing this?
33. When would you use the @future annotation?
Setup,non setup object,api callouts
34. List three different tools that can be used when deploying code.
Eclipse.Ant,CHange set
35. When should an Extension be used instead of a Custom Controller?
36. What are the advantages of using External Id fields?
Import data
37. What are the uses of the <apex:actionFunction> tag?
Calling remote functions from java script
38. What are the differences between static and nonstatic
variables in
Access by class name
39. What are some best practices when writing test classes?
@testsetup,@testvisible,System.assert 3 parameters ,test.starttest,stoptest
40. What does the View State represent in a Visualforce page?
Encrypted data ,state of page
41. What are three new features in the most recent Salesforce release?
42. Describe the benefits of the “One Trigger per Object” design pattern.
43. Write a SOQL query that counts the number of active Contacts for each
Account in a set.
44. Declaratively create logic in your org that prevents two Opportunities
from being created on a single Account in a single day.
45. Declaratively create logic in your org that prevents closed Opportunities
from being updated by a non System Administrator profile.
10) How can you refresh a particular section of a visualforce page?
reRender on apex outputpanel
11) What is the difference between Custom Setting and Custom Labels and Custom Object?
12) What is the Difference between Managed Package and Unmanaged package?
Ans Managed Package code cant be edited
13) How do we capture the user Data in VisualForce page?
14) What are the different Annotations in Salesforce and tell me with examples?
@isTest,@TestVisible,@Override @testsetup,@future, @AuraEnabled
● @Deprecated,@ReadOnly
● @InvocableMethod
● @InvocableVariable
15) What is a difference between System log and debug log?
System log includes all workflow,apex ,workflow debug log include dat in System.debug
16) How to undeployed from deployed items?
17) Difference between import wizard vs dataloader?
18) Describe about the SOQL injection?
19) What is the difference between 15 and 18 Digit ID ?
Case sensitive
20) What is dynamic pick list?
21) Difference between datatable
vs page block table in visualforce page?
● PageBlockTable should be define inside pageblock or pageblocksection.
● PageBlockTable uses standard styles sheets to design a visualpage.
● It has the required attribute “value”.
● Column headers will be displayed automatically.
● No need to write inside pageblock or pageblocksection.
● There is no required value.
● The data can be displayed using custom style sheets.
● we need to specify column headers explicitly.
22) What is render, rerender, renderas ?
23) Difference b/w isblank and isnull?
Isblank for all fields isnull for number
24) Why do we Use system assert in Test Class?
To check values
25) How can we prevent to cross the governor limit from soql query?
26) What is the difference between Sales Cloud and Service Cloud?
27) What is the stages of Opportunity?
28) What is a Batch Apex?
29) What are the different methods in test Class?
Testsetup testmethod
30) What are the different ways to make a field Mandatory?
31) What are the different ways to Share a record?
Role,profile,manual sharing object__share
32) What is the difference between Salesforce license and License?
33) What are the difference between Render as and Rerender?
34) Why do we use Set, List and Map? give an example for it?
35) Can we create a new User without Role and Profile?
Q1 . Precautions to take to convert Master detail into lookup?
Ans . First we should remove any rollup summary field that may be preset delete from deleted
field also and then convert
How to enable community in salesforce?
Go to community settings and then enable community checkbox
Q2 . What is Postinstall script
Q3.How to add members in community ?
Ans Add basis of Profile,Permission set,Public groups
Q4.create vf page for community
Q5.diff b/w role and profile
Ans. Roles will override the permission of profiles.
When to use permission set & when to use profile
Ans. Permission set are used to extend the permission for a parti
Different types of edition
Change type of fields cautions to take
Ans create new field take backup with dataloader ,massupdate records using script delete
ununused field now
How to create Roll up summary for lookup field
Data loader limitation?
Ans 50k records only can insert
How are picklist values internally stored inside salesforce?
Ans Comma separated
Package versioning sf
Deleting fields in production org
Add value in picklist
Delete standard profiles?
Ans No an only edit standard profile cannot delete
Junction object creation
Using 2 master details
add reporting Indexing for formula fields
Controller, extensions usage
COntroller used for custom functionality FLS functionailty not repected,extension to override
some functionality and some to use standard functionality
Wrapper class?
ANs used for relating unrelated data to show on a page
Page block table apex repeat diff diff and how
Different between sf platform and java platform
How is sandbox refreshed
Ans. In the prod. Env. on profile you must have manage sandbox permission checkbox checked. If
you have that permission the from setup you can search for sandbox and the you will see list of
sandbox with that prod. By clicking on refresh link you can refresh it.
Time taken for sandbox refreshing
Ans partial 7 days full 29 days
Security model of sfdc, layers
Types of deployment change set,eclipse ant in which we scenario prefer to remove a field
Can we remove existing field in production?


Connect to a remote System using SSH on Ubuntu


SSH is protocol to log onto remote system and executing command onto remote system. It is mainly used to access Linux and Unix system.  To connect to remote system in ubuntu we uses SSH command. SSH stand for secure shell which allow to access remote system in secure way.

ssh <username>@<domain name or IP address of remote system>


ssh devender@

In Ubuntu SSH can be directly used on terminal. In windows we need one extra program to run. This can be putty. Putty allow a window user to to connect remote Linux machine.

That’s all in this post. Hope this is helpful for you.


How to import sql file in mysql


In last tutorial we seen how to take db dump in mysql. In this post we will see how to import DB sql file. In mysql if your sql file is less than 12 MB then you can import it through workbench like phpmysql or sqlyog. But if file size is larger than 12 MB then we can import it through terminal in ubuntu or command line tool in windows.
dev@devender-G:~$ mysql -u root -p new_test_db < /home/devendar/filename.sql
Enter password:

That all in this post. Hope this is helpful to you.


how to take db dump in mysql


Very often developer needs DB backup before deploying new changes on production environment or any other environment.  In this post we will see how to take backup in mysql db. It is very simple.

mysqldump -u dbusername -p DBname | gzip > filename.sql.gz
Enter password:

That all. It is very simple.



Ubuntu Useful Commands

In this post of tutorials we will see some of very useful command of Ubuntu. Linux system are better than windows. We get more productivity and as a developer it feel better working on linux system than windows system. Personally i always prefer Ubuntu. Here are some of very useful commands that we use most often.

rsync command

This is one of most important command for Ubuntu users. rsync command is used to copy any file of directory from one Ubuntu system to other Ubuntu system.

Here is syntax of rsync command when you are sending some file  from your system to other system.

rsync -avz  <directory or file path> <space> <username of remote system>@<IP address of remote system>:<Intended directory of remote system>


rsync -avz /home/dev/preprod/WebContent/education.jsp javafreakers@

When you transfer some file from remote machine to local machine

rsync -avz javafreakers@ /home/dev/

Optionally you can add –progress after -avz to see progress of file transfer like below

rsync -avz –progress javafreakers@ /home/dev/



Most important java/JEE interview question and concept

In this post of java tutorial we will see some of most important java interview question. These questions are asked most frequently. Although question may vary depending on the interviewer , experience level and job profile but these are some basic question that you may face.  These questions are mixed from core java, java concept, collection String, jsp, servlet , hibernate, spring, sql , database and web technologies. If you have applied for java developer then most of question start with OOPs concept. Then based on your response they interview proceed.

  • What are OOPs concept.
  • What is abstraction.
  • What is encapsulation.
  • What is Difference in encapsulation and abstraction.
  • What is polymorphism.
  • What is inheritance.
  • Difference in jsp and servlet.
  • Why tomcat does not require restart when there is any change in jsp file.
  • What is code written in jsp compiled servlet file.
  • What is the use of wrapper classes in java.
  • Difference in set and list.
  • Can we call destroy method explicitly in servlet.
  • Primitive values cannot be stored in a collection directly. Why ?
  • What if parent class of a serialized class not serialized. In this case parent class fields would be serialized or not.
  • What if child class of a serialized class not serialized. In this case child class fields would be serialized or not.
  • Why we mostly use primary key to retrieve record even we can retrieve record with unique also.
  • Difference in unique key and primary key.
  • What is concurrentHashMap. In which situation you will use concurrentHashMap.
  • Difference in hashtable and hashmap.
  • Difference in truncate and delete.
  • Difference in truncate and drop.
  • Difference in wait() and join() methods.(Sapn Infotech)
  • What is web.xml. (Sapn Infotech)
  • What is application context. (Sapn Infotech)
  • What is serialization and externalization. (Sapn Infotech)
  • Does collection store actual object or reference.
  • Why collection does not store actual object.
  • Difference in delete and drop.
  • What is transaction.
  • How to read file in java. Which classes are used. Write a small program.
  • What is acid property.
  • How to maintain session in spring mvc.
  • Session is class or interface.
  • How many ways are there to maintain user state.
  • Difference in Cookie and session.
  • Boolean.TRUE or true which one is better.
  • Difference in having and where.
  • What is caching in hibernate.
  • What is benefits of query caching.
  • What is Named query. why it is useful.
  • Benefits of hibernate over jdbc.
  • What is Named query. why it is useful.
  • Benefits of hibernate over jdbc.
  • Why String is immutable in java.
  • How we can configure thread session in hibernate.
  • What are proxy class in hibernate.
  • What is difference in get and post post method.
  • How servlet works.Servlet request flow. Complete flow from starting of client request till the response returned to client.
  • Difference between list and set.
  • Difference in DDL and DML.
  • What is sorted set and treeSet.
  • Internal working of hashMap.
  • Lifecycle of spring bean.
  • Servlet life cycle.
  • What is marker interface.(FIS- compatibility with certain operations).
  • Feature added in java5 and java7 and java 8(FIS).
  • select 1 from table limit 10. What will be result.(FIS).
  • Select * from table1,table2 . What will be result.(FIS).
  • How to get Metadata about table result returned and about database.(FIS).
  • Clone method implementation. What are different type of cloning is possible.(FIS).
  • What is double check locking in singleton design pattern.
  • What is benefits of spring framework in details.
  • What is benefits of hibernate over JDBC.
  • What is difference in object level synchronization and class level synchronization.
  • Benefits of Encapsulation.
  • How we can break encapsulation.
  • Can we access parent class method after overriding it in subclass.
  • Difference in String buffer and StringBuilder.
  • What is hashing. How Hashmap work internally based on hashing concept.
  • What is IOC in spring.
  • Explain Inversion of control is design pattern.
  • Which hibernate api you have used.
  • All the task you have done in project till now.
  • When will you choose interface and when will you choose abstract class.
  • what is servlet. How many ways we can create servlet.
  • What is difference between extending genericservlet and extending httpservlet.
  • Why don’t we create servlet by implementing servlet interfaces instead of extending httpservlet.
  • What StringBuffer and stringBuilder differences.
  • When to use StringBuffer and when to use stringBuilder.
  • servlet life cycle.(Adobe Chandigarh Drive 17 January).
  • If we create constructor then init will be called first or constructor will be called first.(Adobe Chandigarh Drive 17 January).
  • How we create servlet. (Adobe Chandigarh Drive 17 January).
  • What is Thread Executor framework.(Adobe Chandigarh Drive 17 January).
  • how to synchronize list , map.(Adobe Chandigarh Drive 17 January).
  • What are synchronized methods and synchronized statements?
  • Difference in Hashmap , hashtable and concurrentHashMap.
  • Can a thread go in runnable state twice. i.e if a thread is in running state can it go in rubbable state again.
    String is class or data type ?
  • Why char array is better than string to store password.

Oracle Database Connectivity example in java

Hi in this post we will see JDBC connectivity of oracle DB. I am writing this post because when i was trying it for my own then i faced one problem which i will discuss later in this post. Direct solution to this problem is not available  on stackoverflow or any other website.  Let see

When you will run this program then it will show expected output shown below

User Name for user 1 devbabu password password
User Name for user 1 ankitjain password ankitpass
User Name for user 1 dheeraj password terapasskyah
User Name for user 1 rekha password thakur

The problem that i was facing was because i am used with mysql we give DB name after port number. but in oracle we give service name of oracle. Second problem that i faced is for port number. When i run oracle in browser then i see So i thought port number is 8080. But it is not true. The default port number that oracle uses is 1521.  Here is the exception that we got because of wrong port number and without oracle service name. “jdbc:oracle:thin:@localhost:8080:dbusername”

Exception in thread “main” java.sql.SQLException: Io exception: Got minus one from a read call

Then after some google i found out that i was using wrong port number 8080 so i changed url string for correct port number as follow “jdbc:oracle:thin:@localhost:1521:dbusername”  but i still have not mention oracle service name. so i end up with following exception

Exception in thread “main” java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:


then after some google i modified url string for service name of oracle DB as follow and everything worked fine for me.  “jdbc:oracle:thin:@localhost:1521:xe” 

Please Note here xe is service name not DB name which you might be using if you are used to with mysql. 


Hope this post will help some one for sure. Have a nice week day. 🙂


get servletContext object in simple java class

In this post of servlet tutorial we will see how to get get servletContext object in simple java class. Few days back i encounter problem related to servletContext. In my problem i was need to get getRealPath of upload folder in my application deployment directory. The pain point of the problem was that eclipse deploy application in .metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ directory but in production environment this path is different. To get real path of any file in application deployment repository we may use servletcontext object. 

To get servletcontext in simple java class we need to implements ServletContextListener in a class . In ServletContextListener we may take a a field of ServletContext type and can access this field in any class in application.

Class that implements ServletContextListener can also be used to do other stuff in application startup phase. For example creating JDBC connection and other type of initialization task. Such class also need to be register as listener in web.xml. Let see the class that implement ServletContextListener

In ServletContextListner class i have set attribute friendListin setvletcontext object which we can access any where in application now. On application startup contextInitialized method is invoked . Here in this method we can also do other task like making jdbc connection or fetching some values from DB after creating connection etc.


We need to register ServletContextListener implementation class as listener in web.xml.

in TestApplicationContext class we have accessed attribute that set up at application initialization time in ServletContextListner class. Also we have printed path of web.xml file of our application. When i invoked testApplicationContext() method of TestApplicationContext class i got this output on my console

Ankit Jain
Ankush Jain
Devender Kumar
Dheeraj Chaudhary
Kishor Kumar Mali
Kuldeep Mishra
Narayan Lal

This is all in this post of servlet tutorial. hpe this was useful to you. If you find any scope of improvment in it please do share it with me.