Hi Friends,
In this post I'm sharing interview questions asked in Rocketalk.
Question 1:
What are the data storage options on android platform?
Answer:
Android platform provides a list of data storage options. These options must be used based on the need such as data is secured and used with permission only or can be accessed publicly.
List of Data storage options in android platform:
Question 2:
Which method is called only once in Fragment lifecycle?
Answer:
In fragment lifecycle method calls, onAttached() is the method which is called only once.
Question 3:
Can we use String in switch case?
Answer:
We can use String in switch case from java 7.
Note: switch uses string.equals() method to compare the passed value with case values, so make sure to add a NULL check to avoid NullPointerException on the string passed.
According to java 7 documentation , java compiler generates more efficient bytecode for String in switch statement than chained if-else-if statements.
Question 4:
Why char array is preferred over String for storing password?
Answer:
String is immutable and final and it's value cannot be changed. So it's a security risk, as it takes time to garbage collect that string value and it resides in memory.
So, always use char array so that it's value can be changed to null.
Also , if string object is printed by mistake in some logs statement, then it prints the actual value, while char array prints memory location.
Question 5:
Why String is popular HashMap key?
Answer:
String is immutable and it's hashcode is calculated once and doesn't need to calculate again. It makes it a good candidate as HashMap key.
Question 6:
Find maximum repetitions of a number in integer array.
Answer:
First create a HashMap, a int variable max and an int variable temp.
HashMap: Stores key-value pairs
max : maximum count of occurences of a number
temp: number with maximum occurences till time
Steps to solve this problem are:
Question 7:
What are the technologies required in Web application development?
Answer:
In Web application development, technologies are required on client side and server side.
Below is the list of technologies required:
Client side development: HTML, CSS, JavaScript, Angular, Ajax
Server side development: PHP, Java , .NET, Perl, Python
Question 8:
What is the difference between Web server and Application server?
Answer:
Web server is basically used to provide static content. While Application server contain the main business logic.
The clients for Web server are Web Browsers, Mobile app etc.
The clients for Application server are Web Server, Application servers, Mobile devices etc.
Most of the application servers also contain Web server as integral part of the system.
Examples of Web servers are : Tomcat, JBoss
Examples of Application servers are : Weblogic, WebSphere etc.
That's all friends.
Hope this post help everybody in clearing java/android interviews.
Thanks for reading.
Question 1:
What are the data storage options on android platform?
Answer:
Android platform provides a list of data storage options. These options must be used based on the need such as data is secured and used with permission only or can be accessed publicly.
List of Data storage options in android platform:
- SharedPreferences : It stores data in XML files.
- SQLite : It stores structured data in the private database.
- Internal Storage : It stores data in device file system.
- External Storage : Data is stored in device's file system but is accessible to all apps on the device.
Question 2:
Which method is called only once in Fragment lifecycle?
Answer:
In fragment lifecycle method calls, onAttached() is the method which is called only once.
Question 3:
Can we use String in switch case?
Answer:
We can use String in switch case from java 7.
Note: switch uses string.equals() method to compare the passed value with case values, so make sure to add a NULL check to avoid NullPointerException on the string passed.
According to java 7 documentation , java compiler generates more efficient bytecode for String in switch statement than chained if-else-if statements.
Question 4:
Why char array is preferred over String for storing password?
Answer:
String is immutable and final and it's value cannot be changed. So it's a security risk, as it takes time to garbage collect that string value and it resides in memory.
So, always use char array so that it's value can be changed to null.
Also , if string object is printed by mistake in some logs statement, then it prints the actual value, while char array prints memory location.
Question 5:
Why String is popular HashMap key?
Answer:
String is immutable and it's hashcode is calculated once and doesn't need to calculate again. It makes it a good candidate as HashMap key.
Question 6:
Find maximum repetitions of a number in integer array.
Answer:
First create a HashMap, a int variable max and an int variable temp.
HashMap: Stores key-value pairs
max : maximum count of occurences of a number
temp: number with maximum occurences till time
Steps to solve this problem are:
- Check whether a key exists in HashMap or not. If it exists , then get its count value, increment it by 1 and put it back and if this new incremented value is > max, then update max with this new value. And also put this new key in temp variable.
- This way, keep iterating and follow step 1 and atlast value stored in temp variable will be the key with max occurences and integer max will give total maximum count of that key.
Question 7:
What are the technologies required in Web application development?
Answer:
In Web application development, technologies are required on client side and server side.
Below is the list of technologies required:
Client side development: HTML, CSS, JavaScript, Angular, Ajax
Server side development: PHP, Java , .NET, Perl, Python
Question 8:
What is the difference between Web server and Application server?
Answer:
Web server is basically used to provide static content. While Application server contain the main business logic.
The clients for Web server are Web Browsers, Mobile app etc.
The clients for Application server are Web Server, Application servers, Mobile devices etc.
Most of the application servers also contain Web server as integral part of the system.
Examples of Web servers are : Tomcat, JBoss
Examples of Application servers are : Weblogic, WebSphere etc.
That's all friends.
Hope this post help everybody in clearing java/android interviews.
Thanks for reading.
No comments:
Post a Comment