Posts

Showing posts from February, 2020

String based Java Interview questions and answers

Image
Difference between String, String Builder, and String Buffer. Ans: String:  String variables are stored in “constant string pool”. Once the string reference changes the old value that exists in the “constant string pool”, it cannot be erased. Example: String name = “book”; Constant string pool . If the name value has changed from “book” to “pen”. Constant string pool Then the older value retains in the constant string pool. String Buffer: Here string values are stored in a stack. If the values are changed then the new value replaces the older value. The string buffer is synchronized which is thread-safe. Performance is slower than the String Builder. Example: String Buffer name =”book”; Once the name value has been changed to “pen” then the “book” is erased in the stack. String Builder: This is same as String Buffer except for the String Builder which is not threaded safety that is not synchronized. So obviously performance is fast.

Battery optimization based Android interview questions and answers

What is doze mode? Device enters doze mode if, an user leaves it unplugged and stationary for a period of time, with the screen off. In doze mode network access and and CPU-intensive services are restricted. Periodically, the system exits Doze for a brief time to let apps complete their deferred activities. Systems exits doze mode if user wakes the device by moving it, turning on the screen, or connecting a charger. Reference http://developer.android.com/training/monitoring-device-state/doze-standby.html What is App Standby? An application goes to App Standby mode if the user does not touch the app for certain period of time and none of the following conditions happened: you explicitly launch the app The app has a process currently in the foreground The app produces a notification When in standby mode, network access and background sync jobs are restricted. When user plugs the device into a power supply, system releases apps from standby mode. Reference http://developer.android.com/tra

Oops based Java Interview Questions and Answers

Image
Class and Object : constructor, local and instance variable,  What do you mean by Constructor? Ans: The points given below explain what a Constructor is in detail: When a new object is created in a program a constructor gets invoked corresponding to the class. The constructor is a method which has the same name as class name. If a user doesn’t create a constructor implicitly a default constructor will be created. The constructor can be overloaded. If the user created a constructor with a parameter then he should create another constructor explicitly without a parameter. What is meant by Local variable and Instance variable? Ans: Local variables  are defined in the method and scope of the variables that have existed inside the method itself. An instance variable  is defined inside the class and outside the method and scope of the variables exist throughout the class. What is a Class? Ans:  All Java codes are defined in a class. A Class has variables and methods.