Hi friends,
In this post I'm sharing Java interview questions asked in Altran.
You may also find my other interview posts very useful.
Java Interview Questions asked in Altran:
Question 1:
How does HTTPS work?
Answer:
In HTTPS, every message is encrypted or decrypted by use of public/private keys.
So, we need to trust that public key cryptography and signature works.
- Any message encrypted with Google's public key can only be decrypted with Google's private key.
- Anyone with access to Google's public key can verify that a message (signature) could only have been created by someone with access to Google's private key.
Question 2:
What is a Certificate Authority? How is a certificate signed?
Answer:
Suppose youtube.com web server uses HTTP currently. And now youtube wants to secure communication using HTTPS.
Also there is Google CA which is considered as a trusted certificate authority.
As any party envolved in public key cryptography , the google certificate authority has a private key and a public key.
As youtube.com wants to communicate using HTTPS, they also need to create a new pair: public key and private key.
Now youtube.com web server creates a Certificate signing request with this key pair.
So most of the browsers [when they are delivered] has a list of these certificates issued by known Certificate Authorities [Google, Symantec, Thwate].
So, when we try to open youtube.com, then as youtube.com uses HTTPS, it sends certificate to the browser. As browser knows the Google's public key [as it is having that certificate with Google's public key], so it can use that key to know that this certificate is actually signed by trusted certificate authority [Google].
Means. now that public key can be used to create and encrypt a secret key which will then be used in symmetric encryption.
Question 3:
Explain the difference between HTTP, HTTPS, SSL and TLS?
Answer:
HTTP: Hyper Text Transfer Protocol
Using this protocol, data is transferred in clear text.
HTTPS: Secure Hypertext Transfer Protocol
Means, HTTP with a security feature.
Encrypts the data that is being retrieved by HTTP. So, it uses encryption algorithms to encrypt the data.
HTTPS uses SSL [Secure Socket Layer] protocol to protect the data.
SSL: This protocol is used to ensure security on the internet. Uses public key encryption to secure data.
TLS: Transport Layer Security
It is the latest industry standard cryptographic protocol. It is a successor to SSL.
And it is based on same specifications.
And like SSL, it also authenticates the server, client and encrypts the data.
Question 4:
What are the collection types in hibernate?
Answer:
Below is the list of collection types in hibernate:
- Bag
- List
- Map
- Array
- Set
Question 5:
What is hibernate proxy?
Answer:
Mapping of classes can be made into a proxy instead of a table.
A proxy is returned when actually a load() is called on a session. The proxy contains actual method to load the data.
The proxy is created by default by hibernate for mapping a class to a file.
Question 6:
What is the difference between load() and get() methods in hibernate?
Answer:
Hibernate's session interface provides several overloaded load() [It will not hit database] methods for loading entities. Each load() method requires the object's primary key as an identifier and it is mandatory to provide it.
In addition to the ID, hibernate also needs to know which class or entity name to use to find the object with that ID.
In case of get() method, we will get return value as NULL if identifier is absent.
But in case of load() method, we will get a runtime exception [ObjectNotFoundException].
When we call load() on hibernate's session object, then hibernate doesn't make a call to database. It creates and returns a proxy object. Now, when some state is fetched from the proxy object, then hibernate issues the appropriate SQL statement to database and builds the real persistent object.
So, when actual data is requested using proxy object and if no data exist for the identifier [id], then ObjectNotFoundException is thrown.
On the other hand, when we call get() method on hibernate's session object, then hibernate immediately issues a SQL statement to the database to fetch associated data [usually a row in database] to rebuild the requested persistent object.
So, if no data is found for the requested identifier [id], the method will return null.
That's all for this post.
Thanks for reading!!
Thanks.
ReplyDeletegood stuff