Ads

Monday 28 July 2014

Pano - Display a 360 degree panoramic image

Download   Demo


Pano is a jQuery plugin to display a 360 degree panoramic image


1. INCLUDE JS FILES


<script src="//code.jquery.com/jquery-1.8.3.js"></script>
<script src="jquery.pano.js"></script>

2. HTML


<div id="myPano" class="pano">
<div class="controls">
<a href="#" class="left">&laquo;</a>
<a href="#" class="right">&raquo;</a>
</div>
</div>

3. JAVASCRIPT


$(document).ready(function()
$("#myPano").pano(
img: "./sphere.jpg"
);
);

4. OPTIONS


.pano 
width: 100%;
height: 100%;
margin: 0 auto;
cursor: move;

.pano .controls
position: relative;
top: 40%;

.pano .controls a
position: absolute;
display: inline-block;
text-decoration: none;
color: #eee;
font-size: 3em;
width: 20px;
height: 20px;

.pano .controls a.left
left: 10px;

.pano .controls a.right
right: 10px;

.pano.moving .controls a
opacity: 0.4;
color: #eee;

5. OPTIONS


img - The URL to the background image. This should be a 360 degree panoramic image. You should set the CSS so that the width and height of the containing block are your desired size.


It will add a class of .moving whenever the background image is being moved (whether drag & drop or via the controls).



Pano - Display a 360 degree panoramic image

Sunday 27 July 2014

jQuery Steps - A powerful wizard plugin

Download   Demo


jQuery Steps is a smart UI component which allows you to easily create wizard-like interfaces. This plugin groups content into sections for a more structured and orderly page view. Furthermore, it is as simple as 1-2-3 to add plugins such as jQuery Validation which can prevent step changing or submission.


Features



Accessability support

Make it visible for everyone without extra work – just use it.

Async content loading

Load your content asynchronously via AJAX by calling e.g. aREST service.

Cool transition effects

Beautiful & sleek transition effects complete the offer.

Dynamic Manipulation

Add or remove steps dynamically via API.

Easy Navigation

Navigate in various different way using the keyboard, steps or pager – it is up to you.

State Persistence

Enable the saveState option – this will save your current step position of each individual wizard *.

Form validation made easy

Embed a validation plugin of your choice and customize it like you want – it is just that simple.

Embedded iframe content

Embed your content via an iframe - it feels like it would be a part of your site.

Keyboard navigation

Use your keyboard to navigate through your content.

Multiple wizards

Have multiple wizards on one page or even have nested wizards like you want.

Vertical Navigation

Switch to vertical navigation if you need.

And much more …

Take a look to the examples and learn more about it.


1. INCLUDE JS FILES
<script src="jquery.js"></script> 
<script src="jquery.steps.js"></script>

2. HTML


<div id="wizard">
<h1>First Step</h1>
<div>First Content</div>

<h1>Second Step</h1>
<div>Second Content</div>
</div>

3. JAVASCRIPT


 $("#wizard").steps();

4. SETTINGS


Appearance


































Setting NameDescriptionTypeDefault Value
headerTagThe header tag is used to find the step button text within the declared wizard area.Stringh1
bodyTagThe body tag is used to find the step content within the declared wizard area.Stringdiv
contentContainerTagThe content container tag which will be used to wrap all step contents.Stringdiv
actionContainerTagThe action container tag which will be used to wrap the pagination navigation.Stringdiv
stepsContainerTagThe steps container tag which will be used to wrap the steps navigation.Stringdiv
cssClassThe css class which will be added to the outer component wrapper.Stringwizard
stepsOrientationDetermines whether the steps are vertically or horizontally oriented.String or Integerhorizontalor 0

Templates














Setting NameDescriptionTypeDefault Value
titleTemplateThe title template which will be used to create a step button.String<span class=”number”>#index#.</span> #title#
loadingTemplateThe loading template which will be used to create the loading animation.String<span class=”spinner”></span> #text#

Behaviour






















































Setting NameDescriptionTypeDefault Value
autoFocusSets the focus to the first wizard instance in order to enable the key navigation from the begining iftrue.Booleanfalse
enableAllStepsEnables all steps from the begining if true (all steps are clickable).Booleanfalse
enableKeyNavigationEnables keyboard navigation iftrue (arrow left and arrow right).Booleantrue
enablePaginationEnables pagination (next, previous and finish button) if true.Booleantrue
suppressPaginationOnFocusSuppresses pagination if a form field is focused.Booleantrue
enableContentCacheEnables cache for async loaded or iframe embedded content.Booleantrue
enableCancelButtonShows the cancel button if enabled.Booleanfalse
enableFinishButtonShows the finish button if enabled.Booleantrue
showFinishButtonAlwaysShows the finish button always (on each step; right beside the next button) if true. Otherwise the next button will be replaced by the finish button if the last step becomes active.Booleanfalse
forceMoveForwardPrevents jumping to a previous step.Booleanfalse
saveStateSaves the current state (step position) to a cookie. By coming next time the last active step becomes activated.Booleanfalse
startIndexThe position to start on (zero-based).Integer0

Transition Effects














Setting NameDescriptionTypeDefault Value
transitionEffectThe animation effect which will be used for step transitions.String or Integernone or0
transitionEffectSpeedAnimation speed for step transitions (in milliseconds).Integer200

Events


























Setting NameDescriptionTypeDefault Value
onStepChangingFires before the step changes and can be used to prevent step changing by returningfalse. Very useful for form validation.Eventfunction (event, currentIndex, newIndex) return true;
onStepChangedFires after the step has change.Eventfunction (event, currentIndex, priorIndex)
onCanceledFires after cancelation.Eventfunction (event)
onFinishingFires before finishing and can be used to prevent completion by returning false. Very useful for form validation.Eventfunction (event, currentIndex) return true;
onFinishedFires after completion.Eventfunction (event, currentIndex)

Labels


































Setting NameDescriptionTypeDefault Value
cancelLabel for the cancel button.StringCancel
currentThis label is important for accessability reasons. Indicates which step is activated.Stringcurrent step:
paginationThis label is important for accessability reasons and describes the kind of navigation.StringPagination
finishLabel for the finish button.StringFinish
nextLabel for the next button.StringNext
previousLabel for the previous button.StringPrevious
loadingLabel for the loading animation.StringLoading …

Example



var settings = 
/* Appearance */
headerTag: "h1",
bodyTag: "div",
contentContainerTag: "div",
actionContainerTag: "div",
stepsContainerTag: "div",
cssClass: "wizard",
stepsOrientation: $.fn.steps.stepsOrientation.horizontal,

/* Templates */
titleTemplate: '<span class="number">#index#.</span> #title#',
loadingTemplate: '<span class="spinner"></span> #text#',

/* Behaviour */
autoFocus: false,
enableAllSteps: false,
enableKeyNavigation: true,
enablePagination: true,
suppressPaginationOnFocus: true,
enableContentCache: true,
enableCancelButton: true,
enableFinishButton: true,
preloadContent: false,
showFinishButtonAlways: false,
forceMoveForward: false,
saveState: false,
startIndex: 0,

/* Transition Effects */
transitionEffect: $.fn.steps.transitionEffect.none,
transitionEffectSpeed: 200,

/* Events */
onStepChanging: function (event, currentIndex, newIndex) return true; ,
onStepChanged: function (event, currentIndex, priorIndex) ,
onCanceled: function (event) ,
onFinishing: function (event, currentIndex) return true; ,
onFinished: function (event, currentIndex) ,

/* Labels */
labels:
cancel: "Cancel",
current: "current step:",
pagination: "Pagination",
finish: "Finish",
next: "Next",
previous: "Previous",
loading: "Loading ..."

};


5. STEP OBJECT


Represents an step object.






















Property NameDescriptionTypeDefault Value
titleThe step title (HTML).String“”
contentThe step content (HTML).String“”
contentModeIndicates how the content will be loaded.String or Integerhtml or 0
contentUrlThe URI that refers to the content.String“”

JavaScript Example



$("#wizard").steps("add", 
title: "Step Title",
contentMode: "async",
contentUrl: "data.xml"
);


HTML Example



<div id="wizard">
<h1>Step Title</h1>
<div data-mode="async" data-url="data.xml">
</div>
</div>


6. METHODS


















































Method NameDescriptionParametersReturn Type
addAdds a new step. (chainable)Object stepObject wizard
insertInserts a new step to a specific position. (chainable)Integer index,Object stepObject wizard
removeRemoves a specific step by an given index.Integer indexBoolean
getCurrentStepGets the current step object.-Object step
getCurrentIndexGets the current step index.-Integer
getStepGets a specific step object by index.Integer indexObject step
nextRoutes to the previous step.-Boolean
previousRoutes to the next step.-Boolean
finishTriggers the onFinishing and onFinished event.-void
destroyRemoves the control functionality completely and transforms the current state to the initial HTML structure.-void
skipSkips a certain amount of steps. Not yet implemented!Integer countBoolean

Example



$("#wizard").steps("insert", 0, 
title: "Step Title",
content: "<p>Step Body</p>"
);





jQuery Steps - A powerful wizard plugin

jQuery Age - tracks dates and times as human readable text

Download   Demo


Age is a jQuery plugin that formats and tracks dates and times as human readable text.


1. INCLUDE JS FILES


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js" type="text/javascript"></script>
<script src="javascript/jquery.age.js" type="text/javascript"></script>

2. HTML


<time datetime="2010-01-01T12:00:00Z" class="age">January 1, 2010 12:00</time>
<time datetime="2020-01-01T12:00:00Z" class="age">January 1, 2020 12:00</time>

3. JAVASCRIPT


$('.age').age();

4. OPTIONS


Age supports a number of configuration settings for customizing the language and intervals:


$('.age').age(
interval: 10000,
suffixes:
past: "ago",
future: "until",
,
formats:
now: "now"
singular:
seconds: "a second",
minutes: "a minute",
hours: "an hour",
days: "a day",
weeks: "a week",
months: "a month",
years: "a year",
,
plural:
seconds: "amount seconds",
minutes: "amount minutes",
hours: "amount hours",
days: "amount days",
weeks: "amount weeks",
months: "amount months",
years: "amount years",
,
,
);
);

Age also supports passing in a whitelist of allowed units (i.e. not showing units in weeks or months ever):


$('.age').age( units: ["days", "hours", "minutes"] );


jQuery Age - tracks dates and times as human readable text

Saturday 26 July 2014

jQuery Notific8 - Notifications introduced in Windows 8

Download Demo


Notific8 is a notification plug-in inspired by the notifications introduced in Windows 8 with some web ready restyling and customizations. Notific8 has built in themes and is easy to create new themes for. The plug-in was born from a want for a simply designed yet modern and stylish notification system. The plug-in is also designed to scale based on the page’s font-size setting



Features


  • Notifications slide in and out from the upper right corner of the page

  • Configurable life span of the notification

  • Option to display a heading

  • Theme options (see CSS for built in themes)

  • Ability to make the notification sticky

  • Ability to set up custom settings for reuse without having to type them over and over

  • Ability to set which corner the notifications are shown in

  • Ability to set the z-index
    • Can be set via config/configure or the zindex function




Browser support


Currently supported and testing:


  • Chrome

  • Firefox

  • Safari (Mac only)

  • IE 9+

1. INCLUDE CSS AND JS FILES


<link href="http://willsteinmetz.net/sites/default/public/stylesheets/jquery.notific8.min.css" media="screen" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="http://willsteinmetz.net/libs/javascript/jquery/latest/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript" src="http://willsteinmetz.net/sites/default/public/javascripts/jquery.notific8.min.js"></script>

2. JAVASCRIPT


// basic
$.notific8('My notification message goes here.');
// with a life set
$.notific8('My notification message has a life span.', life: 5000);
// with a heading
$.notific8('My notification has a heading line.', heading: 'Notification Heading');
// with a theme
$.notific8('My notification has a theme.', theme: 'amethyst');
// make the notification sticky
$.notific8('My notification is sticky.', sticky: true);
// change whether to notification is at the top or bottom
$.notific8('My notification is at the bottom.', horizontalEdge: 'bottom');
// change whether to notification is on the left or right
$.notific8('My notification is on the left.', verticalEdge: 'left');
// set the z-index
$.notific8('My notification has a z-index of 1500.', zindex: 1500);
// all options set
$.notific8('My notification with all options.',
life: 5000,
heading: 'Notification Heading',
theme: 'amethyst',
sticky: true,
horizontalEdge: 'bottom',
verticalEdge: 'left',
zindex: 1500
);

// set up your own default settings to save time and typing later
// NOTE this is not required
$.notific8('configure',
life: 5000,
theme: 'ruby',
sticky: true,
horizontalEdge: 'bottom',
verticalEdge: 'left',
zindex: 1500
);

// set the zindex
$.notific8('zindex', 1500);

3. OPTIONS


  • life: number of milliseconds that the notification will be visible (default: 10000)

  • heading: short heading for the notification

  • theme: string for the theme (default: ‘teal’)
    • Custom themes should be named .jquery-notific8-notification.[theme name] in your stylesheet – see note below about custom themes


  • sticky: boolean for whether or not the notification should stick
    • If sticky is set to true, life will be ignored if it is also set


  • horizontalEdge: string value for top or bottom of the page (default: ‘top’)
    • only accepts values ‘top’ and ‘bottom’


  • verticalEdge: string value for left or right of the page (default: ‘right’)
    • only accepts values ‘left’ and ‘right’


  • zindex: integer value for the z-index (default: 1100)
    • this must be set before calling notific8 to create a notification via either config/configure or zindex


All of these settings are available to be configured. The configure function is used if you have specific settings such as theme and life that you want every notification to share. By configuring these settings, they become the new defaults and you don’t have to type them for every notification. The configure function can be called multiple times.




jQuery Notific8 - Notifications introduced in Windows 8

Smint - Sticky Menu Including Navigation Thingy

Download Demo


Smint is a simple jQuery plugin that helps with the navigation on one page style websites.


It has 2 main elements, a sticky navigation bar that stays at the top of the page while you scroll down and menu buttons that automatically scroll the page to the section you clicked on.


1. INCLUDE CSS AND JS FILES


<link href="css/demo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/jquery.smint.js" type="text/javascript" ></script>

2. HTML


<div class="subMenu" >
<div class="inner">
<a href="#sTop" class="subNavBtn">Home</a>
<a href="#s1" class="subNavBtn">Section 1</a>
<a href="#s2" class="subNavBtn">Section 2</a>
<a href="#s3" class="subNavBtn">Section 3</a>
<a href="#s4" class="subNavBtn">Section 4</a>
<a href="#s5" class="subNavBtn">Section 5</a>
<a href="https://twitter.com/rabmyself" class="subNavBtn extLink end">External Link</a>
</div>
</div>

<div class="section s1">
<div class="inner ">
<h1>Section 1</h1>
</div>
</div>

<div class="section s2">
<div class="inner">
<h1>Section 2</h1>
<p><a href="#s4" class="intLink">Internal Link: Jump to Section 4</a></p>
<p><a href="#sTop" class="intLink">Internal Link: Back to Top</a></p>
</div>
</div>



<div class="section s3">
<div class="inner">
<h1>Section 3</h1>
</div>
</div>

<div class="section s4">
<div class="inner">
<h1>Section 4</h1>
</div>
</div>

<div class="section s5">
<div class="inner">
<h1>Section 5</h1>
</div>
</div>

3. JAVASCRIPT


$(document).ready( function() 
$('.subMenu').smint(
'scrollSpeed' : 1000
);
);

4. OPTIONS


SMINT is a simple plugin, so only has an option for how fast the page scrolls.


$('.subMenu').smint(
'scrollSpeed' : 1000
);

The default speed is 500 (half a second) but you can now set that to be whatever you like.



Smint - Sticky Menu Including Navigation Thingy

Google Maps Slider with jQuery

Download Demo


I’m sure it’s partly me getting better at JavaScript, but I found the API quite well done and easy to work with. For one thing, it’s fully evented. That means you can attach event listeners to different thing, like the map itself or things inside the map. A simple example would be if a marker is clicked, you can change the zoom level of the map, change information shown elsewhere on the page, or really anything else you might want to do with JavaScript.


I created a list of locations in an unordered list. Each list item had HTML5 data attributes containing the latitude and longitude of it. It also contained a title and long and short descriptions.When one of these list items is hovered over, I apply a “hover” class to deal with styling, “pan” the map to the new coordinates, and fill out the right area with more information.


HTML


<li data-geo-lat=“41.9786″ data-geo-long=“-87.9047″><h3>O’Hare Airport</h3><p>Flights n’ stuff</p><p class=“longdesc”><strong>About:</strong> O’Hare International Airport has been voted the “Best Airport in North America” for 10 years by two separate sources: Reaaders of the U.S. Edition of Business Traveler Magazine (1998-2003) and Global Traveler Magazine (2004-2007). Travel and Leisure magazine’s 2009 “America’s Favorite Cities” ranked Chicago’s Airport System (O’Hare and Midway) the second-worst for delays, New York City’s airport system (JFK, Newark Liberty, and LaGuardia) being the first.</p></li>



Google Maps Slider with jQuery

fontFlex – jQuery Plugin for Responsive Font Sizes

Download   Demo


jQuery.fontFlex


Lightweight jQuery extension for dynamically changing font sizes according to screen / browser width. Intended to be used with responsive or adaptive CSS layouts.


Installation


Include the latest version of jQuery and jQuery.fontFlex.js in the <head> of your HTML document:



<script src="jQuery.min.js"></script> 
<script src="jQuery.fontFlex.js"></script>


How to Use


Define a default CSS font base by setting font-size: 1em and line-height: 150% on the body or intended element. Declaring the font-size is optional, but highly recommended in case javascript is disabled. Finally, call the plugin on said element.


Syntax Example



$(function() 

// All elements
$('body').fontFlex(14, 20, 70);

// H1 only
$('h1').fontFlex(24, 36, 70);

);


Custom Parameters
min Minimum font-size in pixels
max Maximum font-size in pixels
mid Mid-range buffer. Values ranging from 60 to 70 produce the best results. Lower values produce a larger initial font-size, while higher values produce the opposite. Adjust accordingly to fit your requirements.



fontFlex – jQuery Plugin for Responsive Font Sizes

Friday 25 July 2014

50+ Best, top, Useful or Helpful SEO interview questions

Technical / Tactics


Every SEO prefers certain tactics over others, but familiarity with many could indicate a deeper understanding of the industry. And while every SEO doesn’t need to have a web developer background, having such skills can help set someone apart from the crowd.


  1. Give me a description of your general SEO experience.

  2. Can you write HTML code by hand?

  3. Could you briefly explain the PageRank algorithm?

  4. How you created any SEO tools either from scratch or pieced together from others?

  5. What do you think of PageRank?

  6. What do you think of using XML sitemaps?

  7. What are your thoughts on the direction of Web 2.0 technologies with regards to SEO?

  8. What SEO tools do you regularly use?

  9. Under what circumstances would you look to exclude pages from search engines using robots.txt vs meta robots tag?

  10. What areas do you think are currently the most important in organically ranking a site?

  11. Do you have experience in copywriting and can you provide some writing samples?

  12. Have you ever had something you’ve written reach the front-page of Digg? Sphinn? Or be Stumbled?

  13. Explain to me what META tags matter in today’s world.

  14. Explain various steps that you would take to optimize a website?

  15. If the company whose site you’ve been working for has decided to move all of its content to a new domain, what steps would you take?

  16. Rate from 1 to 10, tell me the most important “on page” elements

  17. Review the code of past clients/company websites where SEO was performed.

  18. What do you think about link buying?

  19. What is Latent Semantic Analysis (LSI Indexing)?

  20. What is Phrase Based Indexing and Retrieval and what roles does it play?

  21. What is the difference between SEO and SEM?

  22. What kind of strategies do you normally implement for back links?

  23. What role does social media play in an SEO strategy?

  24. What things wouldn’t you to do increase rankings because the risk of penalty is too high?

  25. What’s the difference between PageRank and Toolbar PageRank?

  26. Why might you want to use nofollow on an internal link?

Analysis


A big part of SEO involves assessing the effectiveness of a campaign both relative to past performance as well as to competing sites.


  1. Are you familiar with web analytics and what packages are your familiar with?

  2. From an analytics perspective, what is different between a user from organic search results vs. a type-in user?

  3. How do you distinguish the results of your search optimization work from a seasonal change in traffic patterns?

  4. How do you evaluate whether an SEO campaign is working?

  5. What does competitive analysis mean to you and what techniques do you use?

  6. If you’ve done 6 months of SEO for a site and yet there haven’t been any improvements, how would you go about diagnosing the problem?

  7. How many target keywords should a site have?

  8. How do *you* help a customer decide how to their budget between organic SEO and pay-per-click SEM?

  9. You hear a rumor that Google is weighting the HTML LAYER tag very heavily in ranking the relevance of its results – how does this affect your work?

  10. Why does Google rank Wikipedia for so many topics?

Industry Involvement


Is SEO just a job to pay the bills? Nothing wrong with that, but some senior positions can benefit from more enthusiasm and interest that can be measured by work done outside of the office.


  1. If salary and location were not an issue, who would you work for?

  2. In Google Lore – what are ‘Hilltop’, ‘Florida’ and ‘Big Daddy’?

  3. Have you attended any search related conferences?

  4. Google search on this candidates name, (if you cannot find them, that’s a red flag).

  5. Do you currently do SEO on your own sites? Do you operate any blogs? Do you currently do any freelance work and do you plan on continuing it?

  6. Of the well-known SEOs, who are you not likely to pay attention to?

  7. What are some challenges facing the SEO industry?

  8. What industry sites, blogs, and forums do you regularly read?

  9. Who are the two key people – who started Google?

  10. Who is Matt Cutts?

  11. If you were bidding on a contract, what competitor would you most worry about?

Open-Ended


These questions are more about how an answer is given rather than the actual answer. They often scare interviewees, but with no wrong answer they’re actually a good opportunity to shine.


  1. Tell me your biggest failure in an SEO project

  2. What areas of SEO do you most enjoy?

  3. In what areas of SEO are you strongest?

  4. In what areas of SEO are you weakest?

  5. How do you handle a client who does not implement your SEO recommendations?

  6. Can you get “xyz”? company listed for the keyword “Google”? in the first page?

  7. What do you think is different about working for an SEO agency vs. doing SEO in-house?

  8. Why are you moving from your current position and/or leaving any current projects?


50+ Best, top, Useful or Helpful SEO interview questions

52 Best, top, Useful or Helpful SEO interview questions

SEO Questions


  1. What is SEO?

    SEO is a process to increase a visibility of website in search engine such a Google.com, Yahoo.com, Bing.com, MSN.com, Altvista.com and many more. A Website is visible in search engine ranking page.

  2. Why is Importance of SEO?

    It is sophisticated way to sale a product globally via electronic media. SEO is help to Increase the revenue of business and make brand in global market. Nowadays it is very important for the business purpose to make second level of business.

  3. How many types of SEO?

    SEO is mainly two type such as White hat and Back hat SEO. You can say that green hat, yellow hat, red hat, blue hat SEO. This is also part of SEO. All SEO part is define of level of spam in a web page.

  4. What is On-Page SEO?

  5. What is Off-Page SEO?

  6. Role of On Page SEO in Search engine Ranking?

  7. Role of off page SEO in Search Engine Ranking?

  8. Which one has the major role in search engine ranking On-page or Off-page describe?

  9. What is the role of Title Tag in Search engine ranking?

  10. What is the Role of Description Tag in Search engine ranking?

  11. What is Header Tag? How to write the header.

  12. How many types of header tag?

  13. How to Optimize the Image?

  14. How to Optimize the Flash?

  15. How to Optimize Content?

  16. How to optimize internal link?

  17. How to optimize link (Hyperlink)?

  18. What is Pagination?

  19. How to find keyword for business?

  20. How to Do Competitor analysis?

  21. What is Brad cram?

  22.  What is canonical issue and how to resolve?

  23. What is Keyword Density? How to find the keyword density?

  24. What is URL Optimization?

  25. What is 301 redirection?

  26.  What is 302 redirection?

  27. What are 404 errors?

  28. What is Dublin Core?

  29. What is Geo Meta Tags?

  30. What is robots.txt? How to use.

  31. What is XML Sitemaps? How to create XML Sitemaps.

  32. What is Internal Link?

  33. What is External Link?

  34. What is PageRank?

  35. What is Cache Date?

  36. What is keyword proximity?

  37. What is keyword prominent?

  38. What is cloaking?

  39. What is sneaky redirection?

  40. What is heading text or links? How to use?

  41. What is Doorway Page?

  42. What is Scraped Content?

  43. What is Top level Domain?

  44. How to do Articles Submission? How Much Keyword Density is taking EnzineArtilces?

  45. How to Do Directory submission?

  46. How to Do Bookmarking Submission?

  47.  How to Do Classified Submission?

  48. How to Do Blog?

  49. How to Do Press Release?

  50. What is SMO?

  51. List of Work in SMO.

  52. What is cross linking?


52 Best, top, Useful or Helpful SEO interview questions

115 Best, top, Useful or Helpful Core java Developer interview questions and answers

1. What is JVM ? Why is Java called the “Platform Independent Programming Language” ?

A Java virtual machine (JVM) is a process virtual machine that can execute Java bytecode. Each Java source file is compiled into a bytecode file, which is executed by the JVM.


Java was designed to allow application programs to be built that could be run on any platform, without having to be rewritten or recompiled by the programmer for each separate platform. A Java virtual machine makes this possible, because it is aware of the specific instruction lengths and other particularities of the underlying hardware platform.


2. What is the Difference between JDK and JRE ?

The Java Runtime Environment (JRE) is basically the Java Virtual Machine (JVM) where your Java programs are being executed. It also includes browser plugins for applet execution. The Java Development Kit (JDK) is the full featured Software Development Kit for Java, including the JRE, the compilers and tools (like JavaDoc, and Java Debugger), in order for a user to develop, compile and execute Java applications.


3. What does the “static” keyword mean ? Can you override private or static method in Java ?

The static keyword denotes that a member variable or method can be accessed, without requiring an instantiation of the class to which it belongs.


A user cannot override static methods in Java, because method overriding is based upon dynamic binding at runtime and static methods are statically binded at compile time. A static method is not associated with any instance of a class so the concept is not applicable.


4. Can you access non static variable in static context ?

A static variable in Java belongs to its class and its value remains the same for all its instances. A static variable is initialized when the class is loaded by the JVM. If your code tries to access a non-static variable, without any instance, the compiler will complain, because those variables are not created yet and they are not associated with any instance.


5. What are the Data Types supported by Java ? What is Autoboxing and Unboxing ?

The eight primitive data types supported by the Java programming language are:


  • byte

  • short

  • int

  • long

  • float

  • double

  • boolean

  • char

Autoboxing is the automatic conversion made by the Java compiler between the primitive types and their corresponding object wrapper classes. For example, the compiler converts an int to an Integer, a double to a Double, and so on. If the conversion goes the other way, this operation is called unboxing.


6. What is Function Overriding and Overloading in Java ?

Method overloading in Java occurs when two or more methods in the same class have the exact same name, but different parameters. On the other hand, method overriding is defined as the case when a child class redefines the same method as a parent class. Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides.


7. What is a Constructor, Constructor Overloading in Java and Copy-Constructor ?

A constructor gets invoked when a new object is created. Every class has a constructor. In case the programmer does not provide a constructor for a class, the Java compiler (Javac) creates a default constructor for that class.


The constructor overloading is similar to method overloading in Java. Different constructors can be created for a single class. Each constructor must have its own unique parameter list.


Finally, Java does support copy constructors like C++, but the difference lies in the fact that Java doesn’t create a default copy constructor if you don’t write your own.


8. Does Java support multiple inheritance ?

No, Java does not support multiple inheritance. Each class is able to extend only on one class, but is able to implement more than one interfaces.


9. What is the difference between an Interface and an Abstract class ?

Java provides and supports the creation both of abstract classes and interfaces. Both implementations share some common characteristics, but they differ in the following features:


  • All methods in an interface are implicitly abstract. On the other hand, an abstract class may contain both abstract and non-abstract methods.

  • A class may implement a number of Interfaces, but can extend only one abstract class.

  • In order for a class to implement an interface, it must implement all its declared methods. However, a class may not implement all declared methods of an abstract class. Though, in this case, the sub-class must also be declared as abstract.

  • Abstract classes can implement interfaces without even providing the implementation of interface methods.

  • Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.

  • Members of a Java interface are public by default. A member of an abstract class can either be private, protected or public.

  • An interface is absolutely abstract and cannot be instantiated. An abstract class also cannot be instantiated, but can be invoked if it contains a main method.

Also check out the Abstract class and Interface differences for JDK 8.


10. What are pass by reference and pass by value ?

When an object is passed by value, this means that a copy of the object is passed. Thus, even if changes are made to that object, it doesn’t affect the original value.


When an object is passed by reference, this means that the actual object is not passed, rather a reference of the object is passed. Thus, any changes made by the external method, are also reflected in all places.


Java Threads


11. What is the difference between processes and threads ?

A process is an execution of a program, while a Thread is a single execution sequence within a process. A process can contain multiple threads. A Thread is sometimes called a lightweight process.


12. Explain different ways of creating a thread. Which one would you prefer and why ?

There are three ways that can be used in order for a Thread to be created:


  • A class may extend the Thread class.

  • A class may implement the Runnable interface.

  • An application can use the Executor framework, in order to create a thread pool.

The Runnable interface is preferred, as it does not require an object to inherit the Thread class. In case your application design requires multiple inheritance, only interfaces can help you. Also, the thread pool is very efficient and can be implemented and used very easily.


13. Explain the available thread states in a high-level.

During its execution, a thread can reside in one of the following states:


  • Runnable: A thread becomes ready to run, but does not necessarily start running immediately.

  • Running: The processor is actively executing the thread code.

  • Waiting: A thread is in a blocked state waiting for some external processing to finish.

  • Sleeping: The thread is forced to sleep.

  • Blocked on I/O: Waiting for an I/O operation to complete.

  • Blocked on Synchronization: Waiting to acquire a lock.

  • Dead: The thread has finished its execution.

14. What is the difference between a synchronized method and a synchronized block ?

In Java programming, each object has a lock. A thread can acquire the lock for an object by using the synchronized keyword. The synchronized keyword can be applied in a method level (coarse grained lock) or block level of code (fine grained lock).


15. How does thread synchronization occurs inside a monitor ? What levels of synchronization can you apply ?

The JVM uses locks in conjunction with monitors. A monitor is basically a guardian that watches over a sequence of synchronized code and ensuring that only one thread at a time executes a synchronized piece of code. Each monitor is associated with an object reference. The thread is not allowed to execute the code until it obtains the lock.


16. What’s a deadlock ?

A condition that occurs when two processes are waiting for each other to complete, before proceeding. The result is that both processes wait endlessly.


17. How do you ensure that N threads can access N resources without deadlock ?

A very simple way to avoid deadlock while using N threads is to impose an ordering on the locks and force each thread to follow that ordering. Thus, if all threads lock and unlock the mutexes in the same order, no deadlocks can arise.


Java Collections


18. What are the basic interfaces of Java Collections Framework ?
Java Collections Framework provides a well designed set of interfaces and classes that support operations on a collections of objects. The most basic interfaces that reside in the Java Collections Framework are:


  • Collection, which represents a group of objects known as its elements.

  • Set, which is a collection that cannot contain duplicate elements.

  • List, which is an ordered collection and can contain duplicate elements.

  • Map, which is an object that maps keys to values and cannot contain duplicate keys.

19. Why Collection doesn’t extend Cloneable and Serializable interfaces ?

The Collection interface specifies groups of objects known as elements. Each concrete implementation of a Collection can choose its own way of how to maintain and order its elements. Some collections allow duplicate keys, while some other collections don’t.


The semantics and the implications of either cloning or serialization come into play when dealing with actual implementations. Thus, the concrete implementations of collections should decide how they can be cloned or serialized.


20. What is an Iterator ?

The Iterator interface provides a number of methods that are able to iterate over any Collection. Each Java Collection contains the iterator method that returns an Iterator instance. Iterators are capable of removing elements from the underlying collection during the iteration.


21. What differences exist between Iterator and ListIterator ?

The differences of these elements are listed below:


  • An Iterator can be used to traverse the Set and List collections, while the ListIterator can be used to iterate only over Lists.

  • The Iterator can traverse a collection only in forward direction, while the ListIterator can traverse a List in both directions.

  • The ListIterator implements the Iterator interface and contains extra functionality, such as adding an element, replacing an element, getting the index position for previous and next elements, etc.

22. What is difference between fail-fast and fail-safe ?

The Iterator's fail-safe property works with the clone of the underlying collection and thus, it is not affected by any modification in the collection. All the collection classes in java.util package are fail-fast, while the collection classes in java.util.concurrent are fail-safe. Fail-fast iterators throw a ConcurrentModificationException, while fail-safe iterator never throws such an exception.


23. How HashMap works in Java ?

A HashMap in Java stores key-value pairs. The HashMap requires a hash function and uses hashCode and equals methods, in order to put and retrieve elements to and from the collection respectively. When the put method is invoked, the HashMap calculates the hash value of the key and stores the pair in the appropriate index inside the collection. If the key exists, its value is updated with the new value. Some important characteristics of a HashMap are its capacity, its load factor and the threshold resizing.


24. What is the importance of hashCode() and equals() methods ?

A HashMap in Java uses the hashCode and equals methods to determine the index of the key-value pair. These methods are also used when we request the value of a specific key. If these methods are not implemented correctly, two different keys might produce the same hash value and thus, will be considered as equal by the collection. Furthermore, these methods are also used to detect duplicates. Thus, the implementation of both methods is crucial to the accuracy and correctness of the HashMap.


25. What differences exist between HashMap and Hashtable ?

Both the HashMap and Hashtable classes implement the Map interface and thus, have very similar characteristics. However, they differ in the following features:


  • A HashMap allows the existence of null keys and values, while a Hashtable doesn’t allow neither null keys, nor null values.

  • A Hashtable is synchronized, while a HashMap is not. Thus, HashMap is preferred in single-threaded environments, while a Hashtable is suitable for multi-threaded environments.

  • A HashMap provides its set of keys and a Java application can iterate over them. Thus, a HashMap is fail-fast. On the other hand, a Hashtable provides an Enumeration of its keys.

  • The Hashtable class is considered to be a legacy class.

26. What is difference between Array and ArrayList ? When will you use Array over ArrayList ?

The Array and ArrayList classes differ on the following features:


  • Arrays can contain primitive or objects, while an ArrayList can contain only objects.

  • Arrays have fixed size, while an ArrayList is dynamic.

  • An ArrayListprovides more methods and features, such as addAll, removeAll, iterator, etc.

  • For a list of primitive data types, the collections use autoboxing to reduce the coding effort. However, this approach makes them slower when working on fixed size primitive data types.

27. What is difference between ArrayList and LinkedList ?

Both the ArrayList and LinkedList classes implement the List interface, but they differ on the following features:


  • An ArrayList is an index based data structure backed by an Array. It provides random access to its elements with a performance equal to O(1). On the other hand, a LinkedList stores its data as list of elements and every element is linked to its previous and next element. In this case, the search operation for an element has execution time equal to O(n).

  • The Insertion, addition and removal operations of an element are faster in a LinkedList compared to an ArrayList, because there is no need of resizing an array or updating the index when an element is added in some arbitrary position inside the collection.

  • A LinkedList consumes more memory than an ArrayList, because every node in a LinkedList stores two references, one for its previous element and one for its next element.

Check also our article ArrayList vs. LinkedList.


28. What is Comparable and Comparator interface ? List their differences.

Java provides the Comparable interface, which contains only one method, called compareTo. This method compares two objects, in order to impose an order between them. Specifically, it returns a negative integer, zero, or a positive integer to indicate that the input object is less than, equal or greater than the existing object.


Java provides the Comparator interface, which contains two methods, called compare and equals. The first method compares its two input arguments and imposes an order between them. It returns a negative integer, zero, or a positive integer to indicate that the first argument is less than, equal to, or greater than the second. The second method requires an object as a parameter and aims to decide whether the input object is equal to the comparator. The method returns true, only if the specified object is also a comparator and it imposes the same ordering as the comparator.


29. What is Java Priority Queue ?

The PriorityQueue is an unbounded queue, based on a priority heap and its elements are ordered in their natural order. At the time of its creation, we can provide a Comparator that is responsible for ordering the elements of the PriorityQueue. A PriorityQueue doesn’t allow null values, those objects that doesn’t provide natural ordering, or those objects that don’t have any comparator associated with them. Finally, the Java PriorityQueue is not thread-safe and it requires O(log(n)) time for its enqueing and dequeing operations.


30. What do you know about the big-O notation and can you give some examples with respect to different data structures ?

The Big-O notation simply describes how well an algorithm scales or performs in the worst case scenario as the number of elements in a data structure increases. The Big-O notation can also be used to describe other behavior such as memory consumption. Since the collection classes are actually data structures, we usually use the Big-O notation to chose the best implementation to use, based on time, memory and performance. Big-O notation can give a good indication about performance for large amounts of data.


31. What is the tradeoff between using an unordered array versus an ordered array ?

The major advantage of an ordered array is that the search times have time complexity of O(log n), compared to that of an unordered array, which is O (n). The disadvantage of an ordered array is that the insertion operation has a time complexity of O(n), because the elements with higher values must be moved to make room for the new element. Instead, the insertion operation for an unordered array takes constant time of O(1).


32. What are some of the best practices relating to the Java Collection framework ?


  • Choosing the right type of the collection to use, based on the application’s needs, is very crucial for its performance. For example if the size of the elements is fixed and know a priori, we shall use an Array, instead of an ArrayList.

  • Some collection classes allow us to specify their initial capacity. Thus, if we have an estimation on the number of elements that will be stored, we can use it to avoid rehashing or resizing.

  • Always use Generics for type-safety, readability, and robustness. Also, by using Generics you avoid the ClassCastException during runtime.

  • Use immutable classes provided by the Java Development Kit (JDK) as a key in a Map, in order to avoid the implementation of the hashCode and equals methods for our custom class.

  • Program in terms of interface not implementation.

  • Return zero-length collections or arrays as opposed to returning a null in case the underlying collection is actually empty.

33. What’s the difference between Enumeration and Iterator interfaces ?
Enumeration is twice as fast as compared to an Iterator and uses very less memory. However, the Iterator is much safer compared to Enumeration, because other threads are not able to modify the collection object that is currently traversed by the iterator. Also, Iteratorsallow the caller to remove elements from the underlying collection, something which is not possible with Enumerations.


34. What is the difference between HashSet and TreeSet ?

The HashSet is Implemented using a hash table and thus, its elements are not ordered. The add, remove, and contains methods of a HashSet have constant time complexity O(1).


On the other hand, a TreeSet is implemented using a tree structure. The elements in a TreeSet are sorted, and thus, the add, remove, and contains methods have time complexity of O(logn).


Garbage Collectors


35. What is the purpose of garbage collection in Java, and when is it used ?

The purpose of garbage collection is to identify and discard those objects that are no longer needed by the application, in order for the resources to be reclaimed and reused.


36. What does System.gc() and Runtime.gc() methods do ?

These methods can be used as a hint to the JVM, in order to start a garbage collection. However, this it is up to the Java Virtual Machine (JVM) to start the garbage collection immediately or later in time.


37. When is the finalize() called ? What is the purpose of finalization ?

The finalize method is called by the garbage collector, just before releasing the object’s memory. It is normally advised to release resources held by the object inside the finalize method.


38. If an object reference is set to null, will the Garbage Collector immediately free the memory held by that object ?

No, the object will be available for garbage collection in the next cycle of the garbage collector.


39. What is structure of Java Heap ? What is Perm Gen space in Heap ?

The JVM has a heap that is the runtime data area from which memory for all class instances and arrays is allocated. It is created at the JVM start-up. Heap memory for objects is reclaimed by an automatic memory management system which is known as a garbage collector.


Heap memory consists of live and dead objects. Live objects are accessible by the application and will not be a subject of garbage collection. Dead objects are those which will never be accessible by the application, but have not been collected by the garbage collector yet. Such objects occupy the heap memory space until they are eventually collected by the garbage collector.


40. What is the difference between Serial and Throughput Garbage collector ?

The throughput garbage collector uses a parallel version of the young generation collector and is meant to be used with applications that have medium to large data sets. On the other hand, the serial collector is usually adequate for most small applications (those requiring heaps of up to approximately 100MB on modern processors).


41. When does an Object becomes eligible for Garbage collection in Java ?

A Java object is subject to garbage collection when it becomes unreachable to the program in which it is currently used.


42. Does Garbage collection occur in permanent generation space in JVM ?

Garbage Collection does occur in PermGen space and if PermGen space is full or cross a threshold, it can trigger a full garbage collection. If you look carefully at the output of the garbage collector, you will find that PermGen space is also garbage collected. This is the reason why correct sizing of PermGen space is important to avoid frequent full garbage collections. Also check our article Java 8: PermGen to Metaspace.


Exception Handling


43. What are the two types of Exceptions in Java ? Which are the differences between them ?

Java has two types of exceptions: checked exceptions and unchecked exceptions. Unchecked exceptions do not need to be declared in a method or a constructor’s throws clause, if they can be thrown by the execution of the method or the constructor, and propagate outside the method or constructor boundary. On the other hand, checked exceptions must be declared in a method or a constructor’s throws clause. See here for tips on Java exception handling.


44. What is the difference between Exception and Error in java ?
Exception and Error classes are both subclasses of the Throwable class. The Exception class is used for exceptional conditions that a user’s program should catch. The Error class defines exceptions that are not excepted to be caught by the user program.


45. What is the difference between throw and throws ?

The throw keyword is used to explicitly raise a exception within the program. On the contrary, the throws clause is used to indicate those exceptions that are not handled by a method. Each method must explicitly specify which exceptions does not handle, so the callers of that method can guard against possible exceptions. Finally, multiple exceptions are separated by a comma.


45. What is the importance of finally block in exception handling ?

A finally block will always be executed, whether or not an exception is actually thrown. Even in the case where the catch statement is missing and an exception is thrown, the finally block will still be executed. Last thing to mention is that the finally block is used to release resources like I/O buffers, database connections, etc.


46. What will happen to the Exception object after exception handling ?

The Exception object will be garbage collected in the next garbage collection.


47. How does finally block differ from finalize() method ?

A finally block will be executed whether or not an exception is thrown and is used to release those resources held by the application. Finalize is a protected method of the Object class, which is called by the Java Virtual Machine (JVM) just before an object is garbage collected.


Java Applets


48. What is an Applet ?

A java applet is program that can be included in a HTML page and be executed in a java enabled client browser. Applets are used for creating dynamic and interactive web applications.


49. Explain the life cycle of an Applet.

An applet may undergo the following states:


  • Init: An applet is initialized each time is loaded.

  • Start: Begin the execution of an applet.

  • Stop: Stop the execution of an applet.

  • Destroy: Perform a final cleanup, before unloading the applet.

50. What happens when an applet is loaded ?

First of all, an instance of the applet’s controlling class is created. Then, the applet initializes itself and finally, it starts running.


51. What is the difference between an Applet and a Java Application ?

Applets are executed within a java enabled browser, but a Java application is a standalone Java program that can be executed outside of a browser. However, they both require the existence of a Java Virtual Machine (JVM).


Furthermore, a Java application requires a main method with a specific signature, in order to start its execution. Java applets don’t need such a method to start their execution.


Finally, Java applets typically use a restrictive security policy, while Java applications usually use more relaxed security policies.


52. What are the restrictions imposed on Java applets ?

Mostly due to security reasons, the following restrictions are imposed on Java applets:


  • An applet cannot load libraries or define native methods.

  • An applet cannot ordinarily read or write files on the execution host.

  • An applet cannot read certain system properties.

  • An applet cannot make network connections except to the host that it came from.

  • An applet cannot start any program on the host that’s executing it.

53. What are untrusted applets ?

Untrusted applets are those Java applets that cannot access or execute local system files. By default, all downloaded applets are considered as untrusted.


54. What is the difference between applets loaded over the internet and applets loaded via the file system ?

Regarding the case where an applet is loaded over the internet, the applet is loaded by the applet classloader and is subject to the restrictions enforced by the applet security manager.


Regarding the case where an applet is loaded from the client’s local disk, the applet is loaded by the file system loader.


Applets loaded via the file system are allowed to read files, write files and to load libraries on the client. Also, applets loaded via the file system are allowed to execute processes and finally, applets loaded via the file system are not passed through the byte code verifier.


55. What is the applet class loader, and what does it provide ?

When an applet is loaded over the internet, the applet is loaded by the applet classloader. The class loader enforces the Java name space hierarchy. Also, the class loader guarantees that a unique namespace exists for classes that come from the local file system, and that a unique namespace exists for each network source.


When a browser loads an applet over the net, that applet’s classes are placed in a private namespace associated with the applet’s origin. Then, those classes loaded by the class loader are passed through the verifier.The verifier checks that the class file conforms to the Java language specification . Among other things, the verifier ensures that there are no stack overflows or underflows and that the parameters to all bytecode instructions are correct.


56. What is the applet security manager, and what does it provide ?

The applet security manager is a mechanism to impose restrictions on Java applets. A browser may only have one security manager. The security manager is established at startup, and it cannot thereafter be replaced, overloaded, overridden, or extended.


Swing


57. What is the difference between a Choice and a List ?

A Choice is displayed in a compact form that must be pulled down, in order for a user to be able to see the list of all available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.


58. What is a layout manager ?

A layout manager is the used to organize the components in a container.


59. What is the difference between a Scrollbar and a JScrollPane ?

A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.


60. Which Swing methods are thread-safe ?

There are only three thread-safe methods: repaint, revalidate, and invalidate.


61. Name three Component subclasses that support painting.

The Canvas, Frame, Panel, and Applet classes support painting.


62. What is clipping ?

Clipping is defined as the process of confining paint operations to a limited area or shape.


63. What is the difference between a MenuItem and a CheckboxMenuItem ?

The CheckboxMenuItem class extends the MenuItem class and supports a menu item that may be either checked or unchecked.


64. How are the elements of a BorderLayout organized ?

The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.


65. How are the elements of a GridBagLayout organized ?

The elements of a GridBagLayout are organized according to a grid. The elements are of different sizes and may occupy more than one row or column of the grid. Thus, the rows and columns may have different sizes.


66. What is the difference between a Window and a Frame ?

The Frame class extends the Window class and defines a main application window that can have a menu bar.


67. What is the relationship between clipping and repainting ?

When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.


68. What is the relationship between an event-listener interface and an event-adapter class ?

An event-listener interface defines the methods that must be implemented by an event handler for a particular event. An event adapter provides a default implementation of an event-listener interface.


69. How can a GUI component handle its own events ?

A GUI component can handle its own events, by implementing the corresponding event-listener interface and adding itself as its own event listener.


70. What advantage do Java’s layout managers provide over traditional windowing systems ?

Java uses layout managers to lay out components in a consistent manner, across all windowing platforms. Since layout managers aren’t tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems.


71. What is the design pattern that Java uses for all Swing components ?

The design pattern used by Java for all Swing components is the Model View Controller (MVC) pattern.


JDBC


72. What is JDBC ?

JDBC is an abstraction layer that allows users to choose between databases. JDBC enables developers to write database applications in Java, without having to concern themselves with the underlying details of a particular database.


73. Explain the role of Driver in JDBC.

The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each driver must provide implementations for the following classes of the java.sql package:Connection, Statement, PreparedStatement, CallableStatement, ResultSet and Driver.


74. What is the purpose Class.forName method ?

This method is used to method is used to load the driver that will establish a connection to the database.


75. What is the advantage of PreparedStatement over Statement ?

PreparedStatements are precompiled and thus, their performance is much better. Also, PreparedStatement objects can be reused with different input values to their queries.


76. What is the use of CallableStatement ? Name the method, which is used to prepare a CallableStatement.

A CallableStatement is used to execute stored procedures. Stored procedures are stored and offered by a database. Stored procedures may take input values from the user and may return a result. The usage of stored procedures is highly encouraged, because it offers security and modularity.The method that prepares a CallableStatement is the following:







1CallableStament.prepareCall();



77. What does Connection pooling mean ?

The interaction with a database can be costly, regarding the opening and closing of database connections. Especially, when the number of database clients increases, this cost is very high and a large number of resources is consumed.A pool of database connections is obtained at start up by the application server and is maintained in a pool. A request for a connection is served by a connection residing in the pool. In the end of the connection, the request is returned to the pool and can be used to satisfy future requests.


Remote Method Invocation (RMI)


78. What is RMI ?

The Java Remote Method Invocation (Java RMI) is a Java API that performs the object-oriented equivalent of remote procedure calls (RPC), with support for direct transfer of serialized Java classes and distributed garbage collection. Remote Method Invocation (RMI) can also be seen as the process of activating a method on a remotely running object. RMI offers location transparency because a user feels that a method is executed on a locally running object. Check some RMI Tips here.


79. What is the basic principle of RMI architecture ?

The RMI architecture is based on a very important principle which states that the definition of the behavior and the implementation of that behavior, are separate concepts. RMI allows the code that defines the behavior and the code that implements the behavior to remain separate and to run on separate JVMs.


80. What are the layers of RMI Architecture ?

The RMI architecture consists of the following layers:


  • Stub and Skeleton layer: This layer lies just beneath the view of the developer. This layer is responsible for intercepting method calls made by the client to the interface and redirect these calls to a remote RMI Service.

  • Remote Reference Layer: The second layer of the RMI architecture deals with the interpretation of references made from the client to the server’s remote objects. This layer interprets and manages references made from clients to the remote service objects. The connection is a one-to-one (unicast) link.

  • Transport layer: This layer is responsible for connecting the two JVM participating in the service. This layer is based on TCP/IP connections between machines in a network. It provides basic connectivity, as well as some firewall penetration strategies.

81. What is the role of Remote Interface in RMI ?

The Remote interface serves to identify interfaces whose methods may be invoked from a non-local virtual machine. Any object that is a remote object must directly or indirectly implement this interface. A class that implements a remote interface should declare the remote interfaces being implemented, define the constructor for each remote object and provide an implementation for each remote method in all remote interfaces.


82. What is the role of the java.rmi.Naming Class ?

The java.rmi.Naming class provides methods for storing and obtaining references to remote objects in the remote object registry. Each method of the Naming class takes as one of its arguments a name that is a String in URL format.


83. What is meant by binding in RMI ?

Binding is the process of associating or registering a name for a remote object, which can be used at a later time, in order to look up that remote object. A remote object can be associated with a name using the bind or rebind methods of the Naming class.


84. What is the difference between using bind() and rebind() methods of Naming Class ?

The bind method bind is responsible for binding the specified name to a remote object, while the rebind method is responsible for rebinding the specified name to a new remote object. In case a binding exists for that name, the binding is replaced.


85. What are the steps involved to make work a RMI program ?

The following steps must be involved in order for a RMI program to work properly:


  • Compilation of all source files.

  • Generatation of the stubs using rmic.

  • Start the rmiregistry.

  • Start the RMIServer.

  • Run the client program.

86. What is the role of stub in RMI ?

A stub for a remote object acts as a client’s local representative or proxy for the remote object. The caller invokes a method on the local stub, which is responsible for executing the method on the remote object. When a stub’s method is invoked, it undergoes the following steps:


  • It initiates a connection to the remote JVM containing the remote object.

  • It marshals the parameters to the remote JVM.

  • It waits for the result of the method invocation and execution.

  • It unmarshals the return value or an exception if the method has not been successfully executed.

  • It returns the value to the caller.

87. What is DGC ? And how does it work ?

DGC stands for Distributed Garbage Collection. Remote Method Invocation (RMI) uses DGC for automatic garbage collection. Since RMI involves remote object references across JVM’s, garbage collection can be quite difficult. DGC uses a reference counting algorithm to provide automatic memory management for remote objects.


88. What is the purpose of using RMISecurityManager in RMI ?

RMISecurityManager provides a security manager that can be used by RMI applications, which use downloaded code. The class loader of RMI will not download any classes from remote locations, if the security manager has not been set.


89. Explain Marshalling and demarshalling.

When an application wants to pass its memory objects across a network to another host or persist it to storage, the in-memory representation must be converted to a suitable format. This process is called marshalling and the revert operation is called demarshalling.


90. Explain Serialization and Deserialization.

Java provides a mechanism, called object serialization where an object can be represented as a sequence of bytes and includes the object’s data, as well as information about the object’s type, and the types of data stored in the object. Thus, serialization can be seen as a way of flattening objects, in order to be stored on disk, and later, read back and reconstituted. Deserialisation is the reverse process of converting an object from its flattened state to a live object.


Servlets


91. What is a Servlet ?
The servlet is a Java programming language class used to process client requests and generate dynamic web content. Servlets are mostly used to process or store data submitted by an HTML form, provide dynamic content and manage state information that does not exist in the stateless HTTP protocol.


92. Explain the architechure of a Servlet.

The core abstraction that must be implemented by all servlets is the javax.servlet.Servlet interface. Each servlet must implement it either directly or indirectly, either by extending javax.servlet.GenericServlet or javax.servlet.http.HTTPServlet. Finally, each servlet is able to serve multiple requests in parallel using multithreading.


93. What is the difference between an Applet and a Servlet ?

An Applet is a client side java program that runs within a Web browser on the client machine. On the other hand, a servlet is a server side component that runs on the web server.An applet can use the user interface classes, while a servlet does not have a user interface. Instead, a servlet waits for client’s HTTP requests and generates a response in every request.


94. What is the difference between GenericServlet and HttpServlet ?

GenericServlet is a generalized and protocol-independent servlet that implements the Servlet and ServletConfig interfaces. Those servlets extending the GenericServlet class shall override the service method. Finally, in order to develop an HTTP servlet for use on the Web that serves requests using the HTTP protocol, your servlet must extend the HttpServlet instead. Check Servlet examples here.


95. Explain the life cycle of a Servlet.

On every client’s request, the Servlet Engine loads the servlets and invokes its init methods, in order for the servlet to be initialized. Then, the Servlet object handles all subsequent requests coming from that client, by invoking the service method for each request separately. Finally, the servlet is removed by calling the server’s destroy method.


96. What is the difference between doGet() and doPost() ?
doGET: The GET method appends the name-value pairs on the request’s URL. Thus, there is a limit on the number of characters and subsequently on the number of values that can be used in a client’s request. Furthermore, the values of the request are made visible and thus, sensitive information must not be passed in that way.


doPOST: The POST method overcomes the limit imposed by the GET request, by sending the values of the request inside its body. Also, there is no limitations on the number of values to be sent across. Finally, the sensitive information passed through a POST request is not visible to an external client.


97. What is meant by a Web Application ?

A Web application is a dynamic extension of a Web or application server. There are two types of web applications: presentation-oriented and service-oriented. A presentation-oriented Web application generates interactive web pages, which contain various types of markup language and dynamic content in response to requests. On the other hand, a service-oriented web application implements the endpoint of a web service. In general, a Web application can be seen as a collection of servlets installed under a specific subset of the server’s URL namespace.


98. What is a Server Side Include (SSI) ?

Server Side Includes (SSI) is a simple interpreted server-side scripting language, used almost exclusively for the Web, and is embedded with a servlet tag. The most frequent use of SSI is to include the contents of one or more files into a Web page on a Web server. When a Web page is accessed by a browser, the Web server replaces the servlet tag in that Web page with the hyper text generated by the corresponding servlet.


99. What is Servlet Chaining ?

Servlet Chaining is the method where the output of one servlet is sent to a second servlet. The output of the second servlet can be sent to a third servlet, and so on. The last servlet in the chain is responsible for sending the response to the client.


100. How do you find out what client machine is making a request to your servlet ?

The ServletRequest class has functions for finding out the IP address or host name of the client machine. getRemoteAddr() gets the IP address of the client machine and getRemoteHost() gets the host name of the client machine. See example here.


101. What is the structure of the HTTP response ?

The HTTP response consists of three parts:


  • Status Code: describes the status of the response. It can be used to check if the request has been successfully completed. In case the request failed, the status code can be used to find out the reason behind the failure. If your servlet does not return a status code, the success status code, HttpServletResponse.SC_OK, is returned by default.

  • HTTP Headers: they contain more information about the response. For example, the headers may specify the date/time after which the response is considered stale, or the form of encoding used to safely transfer the entity to the user. See how to retrieve headers in Servlet here.

  • Body: it contains the content of the response. The body may contain HTML code, an image, etc. The body consists of the data bytes transmitted in an HTTP transaction message immediately following the headers.

102. What is a cookie ? What is the difference between session and cookie ?
A cookie is a bit of information that the Web server sends to the browser. The browser stores the cookies for each Web server in a local file. In a future request, the browser, along with the request, sends all stored cookies for that specific Web server.The differences between session and a cookie are the following:


  • The session should work, regardless of the settings on the client browser. The client may have chosen to disable cookies. However, the sessions still work, as the client has no ability to disable them in the server side.

  • The session and cookies also differ in the amount of information the can store. The HTTP session is capable of storing any Java object, while a cookie can only store String objects.

103. Which protocol will be used by browser and servlet to communicate ?

The browser communicates with a servlet by using the HTTP protocol.


104. What is HTTP Tunneling ?

HTTP Tunneling is a technique by which, communications performed using various network protocols are encapsulated using the HTTP or HTTPS protocols. The HTTP protocol therefore acts as a wrapper for a channel that the network protocol being tunneled uses to communicate. The masking of other protocol requests as HTTP requests is HTTP Tunneling.


105. What’s the difference between sendRedirect and forward methods ?

The sendRedirect method creates a new request, while the forward method just forwards a request to a new target. The previous request scope objects are not available after a redirect, because it results in a new request. On the other hand, the previous request scope objects are available after forwarding. FInally, in general, the sendRedirect method is considered to be slower compare to the forward method.


106. What is URL Encoding and URL Decoding ?

The URL encoding procedure is responsible for replacing all the spaces and every other extra special character of a URL, into their corresponding Hex representation. In correspondence, URL decoding is the exact opposite procedure.


JSP


107. What is a JSP Page ?

A Java Server Page (JSP) is a text document that contains two types of text: static data and JSP elements. Static data can be expressed in any text-based format, such as HTML or XML. JSP is a technology that mixes static content with dynamically-generated content. See JSP example here.


108. How are the JSP requests handled ?

On the arrival of a JSP request, the browser first requests a page with a .jsp extension. Then, the Web server reads the request and using the JSP compiler, the Web server converts the JSP page into a servlet class. Notice that the JSP file is compiled only on the first request of the page, or if the JSP file has changed.The generated servlet class is invoked, in order to handle the browser’s request. Once the execution of the request is over, the servlet sends a response back to the client. See how to get Request parameters in a JSP.


109. What are the advantages of JSP ?

The advantages of using the JSP technology are shown below:


  • JSP pages are dynamically compiled into servlets and thus, the developers can easily make updates to presentation code.

  • JSP pages can be pre-compiled.

  • JSP pages can be easily combined to static templates, including HTML or XML fragments, with code that generates dynamic content.

  • Developers can offer customized JSP tag libraries that page authors access using an XML-like syntax.

  • Developers can make logic changes at the component level, without editing the individual pages that use the application’s logic.

110. What are Directives ? What are the different types of Directives available in JSP ?

Directives are instructions that are processed by the JSP engine, when the page is compiled to a servlet. Directives are used to set page-level instructions, insert data from external files, and specify custom tag libraries. Directives are defined between
< %@ and % >.The different types of directives are shown below:


  • Include directive: it is used to include a file and merges the content of the file with the current page.

  • Page directive: it is used to define specific attributes in the JSP page, like error page and buffer.

  • Taglib: it is used to declare a custom tag library which is used in the page.

111. What are JSP actions ?

JSP actions use constructs in XML syntax to control the behavior of the servlet engine. JSP actions are executed when a JSP page is requested. They can be dynamically inserted into a file, re-use JavaBeans components, forward the user to another page, or generate HTML for the Java plugin.Some of the available actions are listed below:


  • jsp:include – includes a file, when the JSP page is requested.

  • jsp:useBean – finds or instantiates a JavaBean.

  • jsp:setProperty – sets the property of a JavaBean.

  • jsp:getProperty – gets the property of a JavaBean.

  • jsp:forward – forwards the requester to a new page.

  • jsp:plugin – generates browser-specific code.

112. What are Scriptlets ?

In Java Server Pages (JSP) technology, a scriptlet is a piece of Java-code embedded in a JSP page. The scriptlet is everything inside the tags. Between these tags, a user can add any valid scriplet.


113. What are Decalarations ?

Declarations are similar to variable declarations in Java. Declarations are used to declare variables for subsequent use in expressions or scriptlets. To add a declaration, you must use the sequences to enclose your declarations.


114. What are Expressions ?

A JSP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream returned to the client, by the web server. Expressions are defined between <% = and %> tags.


115. What is meant by implicit objects and what are they ?

JSP implicit objects are those Java objects that the JSP Container makes available to developers in each page. A developer can call them directly, without being explicitly declared. JSP Implicit Objects are also called pre-defined variables.The following objects are considered implicit in a JSP page:


  • application

  • page

  • request

  • response

  • session

  • exception

  • out

  • config

  • pageContext

Still with us? Wow, that was a huge article about different types of questions that can be used in a Java interview.



115 Best, top, Useful or Helpful Core java Developer interview questions and answers