Searching for "snippet"

Q:

Write code snippet to retrieve IMEI number of Android phone?

Answer

TelephonyManager class can be used to get the IMEI number. It provides access to information about the telephony services on the device.


Code


        TelephonyManager mTelephonyMgr = (TelephonyManager)


        getSystemService(Context.TELEPHONY_SERVICE);


        String imei = mTelephonyMgr.getDeviceId();

Report Error

View answer Workspace Report Error Discuss

Q:

What will be the output of the following code snippet?

Object s1 = new String("Hello");
Object s2 = new String("Hello");
 
if(s1 == s2) {
  System.out.println("s1 and s2 are ==");
}else if (s1.equals(s2)) {
  System.out.println("s1 and s2 are equals()");
}

Answer

Answer : s1 and s2 are equals()


 


Explanation :



 

Report Error

View answer Workspace Report Error Discuss

Subject: Java