Infosys Interview Question for Software Engineer / Developers

Country: India
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
of 1 vote

There is a small change required in java when changing form non secure to secure URL (http to https).

Say for example when creating a object for reading an online resource, the only change you would do it instead of http url, you would specify https url.

(Site does not allow me to specify external url in the comments section)


URL url = new URL("http:..//.....");
  URLConnection ucon = url.openConnection();


URL url = new URL("https:..//....");
  URLConnection ucon = url.openConnection();

What happens behind the scene is, when a connection is opened, due to an SSL url mentioned, an SSL handshake activity is performed.

Overall, the SSL handshake has following steps

1. JVM looks for a certificate in the default java keystore. This keystore is usually a cacerts file inside the java installation jre/lib/security folder unless specified separately while instantiating the JVM.
2. If the certificate is not found it throws a handshake error and the program errors out.
3. If the certificate is found, it uses the public key in the certificate to communicate with the secure host. Host uses his private key to decrypt the information sent.

For the browsers thought you might think, you directly access the secure url and never import any certificate as such.
That is because most of the modern browsers come with the bunch of certificates preinstalled. And since most of the sites uses approved CA certs from Certificate authorities like Verisign, you have all those certs pre installed.

So the bottom line is to convert from http to https you dont need much changes in the code other than changing the URL end point from http to https. The behind the scenes work of importing the certificate to the keystore is what is required to make the change work.

- Saurabh July 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 votes

what if the interviewer meant hosting your own site on https only

- raj July 12, 2014 | Flag
Comment hidden because of low score. Click to expand.
of 1 vote

<intercept-url pattern="/secure/**" access="ROLE_USER" requires-channel="https"/>
<intercept-url pattern="/**" access="ROLE_USER" requires-channel="any"/>

- palletilaxminarayana July 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

A list of few more java interview questions like

1. By default, Java is pass by reference or pass by value. how it handles it.
2. In which scenario, you will use custom exceptions in java.
3. how garbage collection works in java

Check more :

- Ashish July 28, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

lem me add few things in it in terms if you are implementing the same thing with context to servlet..

The servlet container should automatically redirect the user to the HTTPS listener if you set the transport-guarantee element to CONFIDENTIAL or INTEGRAL in your web.xml, like so:


- saxenasaral August 18, 2014 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More