Android Interview Questions & Answers

Android Technical Written Questions and Answers

Which of these can be used to fully abstract a class from its implementation?

  1. Objects  
  2. Packages
  3. Interfaces
  4. None of the Mentioned.                  

Answer: 3

Which of these keywords is used by a class to use an interface defined previously?

  1. import
  2. Import
  3. implements
  4. Implements                                 

Answer: 3

 

Which of these operators can be used to concatenate two or more String objects?

  1. +  
  2.  +=   
  3.  &  
  4.  ||                                                           

 

Answer: 1

 

Which of these methods of class String is used to extract a single character from a String object?

  1. CHARAT()
  2. charat()
  3. charAt()
  4. ChatAt()                                 

 

Answer: 3

 

Which of the following can be operands of arithmetic operators?

  1. Numeric
  2. Boolean
  3. Characters
  4. Both Boolean & Characters                

 

Answer: 4

 

What is an activity in Android?

  1. Activity performs the actions on the screen
  2. Manage the Application content
  3. Screen UI
  4. None of the above                                                           

 

Answer: 1

 

What are the layouts available in android?

  1. Linear Layout
  2. Frame Layout
  3. Table Layout
  4. Relative Layout
  5. All of the above                                                                 

 

Answer: 5

 

A type of class that will be responsible to design main screen activity on first time launch of application is called:

  1. Activity class
  2. Parent class
  3. Child class
  4. Inherited class                                                                 

 

Answer: 1

 

Android component that manages appearance and format on screen is called

  1. fragment
  2. intent
  3. view
  4. layout

 

Answer: 4

 

Android component that works like a database

  1. Services
  2. Activities
  3. Broadcast Receivers
  4. Content Providers

 

Answer: 4

 

What is the o/p of the following program?


public class MyClass{

public static void main(String[] args) {

int[] dest = new int[]{0,1,2,3,4,5};

   System.out.println(dest[0]+ dest[5]+dest[2]);

 }

}

 

  1. 052
  2. Compilation Error
  3. 7
  4. 152                                                                       

 

Answer :3

Write a java program to reverse a string?

Solution:  


String str = "MyJava";

char[] strArray = str.toCharArray();

for (int i = strArray.length - 1; i >= 0; i--)
{
 System.out.print(strArray[i]);     //Output : avaJyM
}

 

How do you find duplicate characters in a string?

Solution:       


class DuplicateCharactersInString{

 static void duplicateCharCount(String inputString){

 //Creating a HashMap containing char as key and it's occurrences as value

HashMap<Character, Integer> charCountMap = new HashMap<Character, Integer>();

 //Converting given string to char array

 char[] strArray = inputString.toCharArray();

 //checking each char of strArray

for (char c : strArray)

{

if(charCountMap.containsKey(c))

{

//If char is present in charCountMap, incrementing it's count by 1

            charCountMap.put(c, charCountMap.get(c)+1);

}

else

{
//If char is not present in charCountMap,

  //putting this char to charCountMap with 1 as it's value

 charCountMap.put(c, 1);

  }

}

  //Getting a Set containing all keys of charCountMap

Set<Character> charsInString = charCountMap.keySet();

System.out.println("Duplicate Characters In "+inputString);

 //Iterating through Set 'charsInString'

 for (Character ch : charsInString)

{
 if(charCountMap.get(ch) > 1){

 //If any char has a count of more than 1, printing it's count

               System.out.println(ch +" : "+ charCountMap.get(ch));
 }

 }

  }

   public static void main(String[] args)

  {

 duplicateCharCount("JavaJ2EE");

duplicateCharCount("Fresh Fish");

 duplicateCharCount("Better Butter");

 }

}

Output :

 

Duplicate Characters In JavaJ2EE

E : 2

a : 2

J : 2

Duplicate Characters In Fresh Fish

F : 2

s : 2

h : 2

Duplicate Characters In Better Butter

t : 4

e : 3

r : 2

B : 2

 

How many objects will be created in the following code and where they will be stored?

String s1 = new String(“abc”);

String s2 = new String(“abc”);

 

Two objects will be created and they will be stored in the heap memory.

 

Java program to sum the elements of an array?

 

Solution:


class SumOfArray{

   public static void main(String args[]){

      int[] array = {10, 20, 30, 40, 50, 10};

     int sum = 0;

     //Advanced for loop

      for( int num : array) {

          sum = sum+num;

     }

      System.out.println("Sum of array elements is:"+sum);

   }
}

Output:

 

Sum of array elements is:160

More Interview Questions and Answers on Android:

20 Android Interview Questions and Answers : Basic Level

Android Interview Questions and Answers for freshers

Alok

Alok

A Computer Science graduate, a blogger, a web developer worked on various mobile app development and web technologies.

View all posts by Alok →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.