Sunday, 1 May 2016

Twitter Bootstrap Test

1.Which of the following are not Bootstrap plugins?

  • Transition
  • tocible
  • Tooltip
  • boilerplate
2. Which type of trigger cannot be used with the "delay" option to show and hide a popover?
  • Click
  • hover
  • Focus
  • Manual
3.Which of the following will set a modal window to not be closed on click?

Wednesday, 6 April 2016

C# Test 2016

1. Which of the following define the rules for .NET Languages?
Answers:
• GAC
• CLS
• CLI
• CTS
• CLR
• JIT

2. Suppose there is a List of type Person with a property of LastName(string) and PopulateList is a function which returns a Generic List of type Person:
List<Person> people = PopulateList();

What does the statement below do?
people.Sort((x, y) => string.Compare(x.LastName, y.LastName));
Answers:
• It will return a newly created sorted List.
• It will throw a compiler error.
• It will sort the string in place.
• It will throw InvalidOperationException at runtime.
3. Which of the following will correctly remove duplicates from a List<T>?
Answers:
• Int32 index = 0; while (index < list.Count + 1) { if (list[index] == list[index + 1]) list.RemoveAt(index); else index--; }
• List<T> withDupes = LoadSomeData(); List<T> noDupes = new List<T>(new HashSet<T>(withDupes)); withDupes.AddRange(noDupes);
• List<T> withDupes = LoadSomeData(); List<T> noDupes = withDupes.Distinct().ToList();
• List<T> withDupes = LoadSomeData(); var hs = new HashSet<T>(withDupes); withDupes.All( x => hs.Add(x) );
4. Is it possible to define custom Exception classes in C#?
Answers:
• Yes
• Yes, but they have to be derived from System.Exception class
• Yes, but they have to be derived from System.Object class
• No
5. Which type of class members are associated with the class itself rather than the objects of the class?
Answers:
• Public
• Protected
• Private
• Static
6. What is the syntax required to load and use a normal unmanaged windows DLL (e.g. kernel32.DLL) in a managed .NET C# code?
Answers:
• Assembly.Load(''Kernel32.DLL'')
• LoadLibrary(''Kernel32.DLL'')
• [DllImport(''kernel32'', SetLastError=true)]
• Unmanaged DLLs cannot be used in a managed .NET application.
7. What is the output of the following code?

class Test
{
   static void Main() {
   string myString = “1 2       3  4    5”
   myString = Regex.Replace(myString, @"\s+", " ");
   System.Console.WriteLine(myString);
}
Answers:
• 12345
• 1 2 3 4 5
• 54321
• 5 4 3 2 1
8. Which of the following will block the current thread for a specified number of milliseconds?
Answers:
• System.Threading.Thread.Sleep(50);
• System.Threading.Thread.SpinWait(50);
• System.Threading.Thread.Yield();
• None of these.
9. What is the problem with the following function, which is supposed to convert a Stream into byte array?
public static byte[] ReadFully(Stream input)
{
    using (MemoryStream ms = new MemoryStream())
    {
        input.CopyTo(ms);
        return ms.ToArray();
    }
}
Answers:
• It will work only in .NET Framework 4 or above, as the CopyTo function of the memory stream is available only in .NET Framework 4 or later versions.
• It will work only in .NET Framework 3.5 or below, as the CopyTo function of the memory stream is available only in .NET Framework 3.5 or earlier versions.
• It will work in all versions of the .NET framework.
• None of these.
10. Which of the following functions are used to wait for a thread to terminate?
Answers:
• Wait()
• Terminate()
• Join()
• Abort()
11. _____________ helped overcome the DLL conflict faced by the C# language versions prior to .NET.
Answers:
• CLR
• JIT
• CTS
• GAC
• Satellite Assemblies
• All of these
12. What is the benefit of using a finally{} block with a try-catch statement in C#?
Answers:
• The finally block is always executed before the thread is aborted.
• The finally block is never executed before the thread is aborted.
• The finally block is never executed after the thread is aborted.
• The finally block is always executed before the thread is started.
13. In which of the following namespaces is the Assembly class defined?
Answers:
• System.Assembly
• System.Reflection
• System.Collections
• System.Object
14. Which of the following statements is true regarding predicate delegates in C#?
Answers:
• Predicate delegates are used for filtering arrays.
• Predicate delegates are references to functions that return true or false.
• Predicate delegates are only used in System.Array and System.Collections.Generic.List classes.
• Predicate delegates are only used in ConvertAll and ForEach methods.
15. Working with a list of Employees:
List<Employee> lstEmployees = new List<Employee>
            {
                new Employee{Name="Harry",Age=15},
                new Employee{Name="Peter",Age=22},
                new Employee{Name="John",Age=45},
                new Employee{Name="Harry",Age=15},
                new Employee{Name="Peter",Age=22},
                new Employee{Name="John",Age=45},

            };

It is required to filter out employees having distinct names.
Which one of the following options cannot be used?
Answers:
• public class Employee { public int Age { get; set; } public string Name { get; set; } public override bool Equals(object obj) { return this.Name.Equals(((Employee)obj).Name); } public override int GetHashCode() { return this.Name.GetHashCode(); } } List<Employee> distinctEmployeesByName = lstEmployees.Distinct().ToList();
• public class Employee { public int Age { get; set; } public string Name { get; set; } } public class EmployeeEquityComparable : IEqualityComparer<Employee> { #region IEqualityComparer<Employee> Members public bool Equals(Employee x, Employee y) { return x.Name.Equals(y.Name); } public int GetHashCode(Employee obj) { return obj.Name.GetHashCode(); } #endregion } List<Employee> distinctEmployeesByName = lstEmployees.Distinct(new EmployeeEquityComparable()).ToList();
• public class Employee:IEqualityComparer<Employee> { public int Age { get; set; } public string Name { get; set; } #region IEqualityComparer<Employee> Members public bool Equals(Employee x, Employee y) { return x.Name.Equals(y.Name); } public int GetHashCode(Employee obj) { return obj.Name.GetHashCode(); } #endregion } List<Employee> distinctEmployeesByName = lstEmployees.Distinct().ToList();
• public class Employee { public int Age { get; set; } public string Name { get; set; } } List<Employee> distinctEmployeesByName = (from emp in lstEmployees group emp by emp.Name into gemp select gemp.First()).ToList();
16. What are the benefits of using the ExpandoObject class over a using dictionary?
Answers:
• It offers easier data binding from XAML.
• It's interoperable with dynamic languages, which will be expecting DLR properties rather than dictionary entries.
• WPF data binding will understand dynamic properties, so WPF controls can bind to an ExpandoObject more readily than a dictionary.
• ExpandoObject can help in creating complex hierarchical objects. ExpandoObject implements the INotifyPropertyChanged interface, which gives more control over properties than a dictionary.
17. What will be the output of the following Main program in a C# console application (Assume required namespaces are included):

static void Main(string[] args)
        {
            int @int = 15;
            Console.WriteLine(@int);
            Console.ReadLine();
        }
Answers:
• 15
• It will throw a compilation error.
• It will throw an error at runtime.
• @15
18. What is the purpose of the catch block in the following code?

try { 
    // Code that might throw exceptions of different types 
}

catch { 
    // Code goes here 
}
Answers:
• Only errors of type std::unexpected are caught here.
• Other code exceptions are caught.
• This catch block must be the first one in a series of catch blocks that may or may not be followed.
• This catch block can be the last one in a series of catch blocks to handle any exception which is not handled by the preceding catch blocks, each of which handles an exception of a particular type.
• No errors are caught in this try block (they are all passed to the next closest catch).
• None of these.
19. Which of the following is true about friend functions in C#?
Answers:
• Friend functions violate the concept of OOPS.
• Friend functions should not be used.
• Friend functions enhance the concept of OOPS if used properly.
• Friend functions are not available in C#.
20. Which of the following statements is true about the code below?

string[] lines = theText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
Answers:
• It splits the string variable on a system line break.
• It splits the string variable on a ‘\r\n’ line break.
• It splits the string variable on a system line break, while preserving the empty lines.
• It splits the string variable on a system line break, while removing the empty lines.
21. Consider the following code:

        string s1 = "Old Value";
        string s2 = s1;
        s1 = "New Value";
        Console.WriteLine(s2);

What will be the output printed, and why?
Answers:
• "New Value", because string is a reference type.
• "Old Value", because string is a value type.
• "New Value", because string is a value type.
• "Old Value", because string is a reference type.
• "Old Value", because string is a reference type which is treated as a special case by the assignment operator.
22. What will be the output if in a WinForms application, the following code is executed in the Load event of a form? Assume this form has lblMessage as a Label Control.

private void Form1_Load(object sender, EventArgs e)
{
    try
    {
        ThreadPool.QueueUserWorkItem(ShowMessage,null);
    }
    catch (Exception ex)
    {
    }
}

private void ShowMessage(object obj)
{
    try
    {
        lblMessage.Text = "Hello from Thread Pool";
    }
    catch (Exception ex)
    {
    }
}
Answers:
• lblMessage.Text will be set to "Hello from Thread Pool".
• An InvalidOperationException will be thrown for the function ShowMessage as the UI can be updated only from the UI thread.
• Behavior will vary depending on the form loaded.
• None of these.
23. What are Satellite assemblies in C# .NET?
Answers:
• Additional assemblies that are used only by the main C# application
• User control assemblies used by the C# application
• Assemblies that contain only resource information and no code
• Assemblies that contain only code and no resource information
24. Where does a C# assembly store the information regarding the other external dependencies, such as satellite assemblies, global assemblies etc, and their versions so that they can be loaded correctly when the assembly is executed?
Answers:
• In the embedded resources of the assembly
• In the manifest of the assembly
• In the MSIL of the assembly
• In the Windows registry database
• None of these
25. Which of the following will output the string below?
"\t\t\t\t\t"
Answers:
• private string Tabs(uint numTabs) { IEnumerable<string> tabs = Enumerable.Repeat("\t", numTabs); return (numTabs > 0) ? tabs.Aggregate((sum, next) => sum + next) : ""; }
• private string Tabs(uint numTabs) { StringBuilder sb = new StringBuilder(); for (uint i = 0; i <= numTabs; i++) { sb.Append("\t"); } return sb.ToString(); }
• private string Tabs(uint numTabs) { string output = ""; for (uint i = 0; i <= numTabs; i++) { output += '\t'; } return output; }
• private string Tabs(uint numTabs) { String output = new String('\t', numTabs); return output; }
26. Complete the following sentence:

In C#, exception handling should be used...
Answers:
• to handle the occurrence of unusual or unanticipated program events
• to redirect the programs normal flow of control
• in cases of potential logic or user input errors
• in case of overflow of an array boundary
27. The global assembly cache:
Answers:
• Can store two DLL files with the same name
• Can store two DLL files with the same name, but different versions
• Can store two DLL files with the same name and same version
• Cannot store DLL files with the same name
28. Which statements will give the path where the executing assembly is currently located?
Answers:
• System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
• System.Reflection.Assembly.GetExecutingAssembly().Location;
• AppDomain.CurrentDomain.BaseDirectory;
• None of these
29. In C#, can global functions that are not associated with a particular class be defined?
Answers:
• Yes
• Yes, but they have to be marked with the keyword static.
• Yes, but they have to be marked with the keyword internal.
• No
30. Which of the following code snippets will call a generic method when the type parameter is not known at compile time?
Answers:
• var name = InvokeMemberName.Create; Impromptu.InvokeMemberAction(this, name("GenericMethod", new[]{myType}));
• MethodInfo method = typeof(Sample).GetMethod("GenericMethod"); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null);
• Action<> GenMethod = GenericMethod< myType >; MethodInfo method = this.GetType().GetMethod(GenMethod.Method.Name); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null);
• Action<> GenMethod = GenericMethod< myType >; MethodInfo method = this.GetType().GetMethod("GenericMethod"); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null);
31. Which of the following is true for CLR?
Answers:
• It is an interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data).
• It is a software Output Unit of Deployment and a unit of versioning that contains MSIL code.
• It is the primary building block of a .NET Framework application and a collection of functionality that is built, versioned, and deployed as a single implementation unit.
• All of these.
32. In the sample code given below, which of the data members are accessible from class Y?

class X {
    private int i;
    protected float f;
    public char c;
}

class Y : X { }
Answers:
• c
• f
• i
• All of these
33. If i == 0, why is (i += i++) == 0 in C#?
Answers:
• //source code i += i++; //abstract syntax tree += / \ i i (post) \ ++
• // source code i += i++; //abstract syntax tree += / \ i ++ (post) \ i First, i++ returns 0. Then i is incremented by 1. Lastly i is set to the initial value of i which is 0 plus the value i++ returned, which is zero too. 0 + 0 = 0.
• int i = 0; i = i + i; i + 1;
• int ++(ref int i) { int c = i; i = i + i; return c;}
34. Performance-wise, which of the following is the most efficient way to calculate the sum of integers stored in an object array?
Answers:
• int FindSum(object[] values) { int sum = 0; foreach (object o in values) { if (o is int) { int x = (int) o; sum += x; } } return sum; }
• int FindSum (object[] values) { int sum = 0; foreach (object o in values) { int? x = o as int?; if (x.HasValue) { sum += x.Value; } } return sum; }
• int FindSum (object[] values) { int sum = values.OfType<int>().Sum(); return sum; }
• int FindSum (object[] values) { int sum = 0; foreach (object o in values) { if (o is int) { int x = Convert.ToInt32(o); sum += x; } } return sum; }
35. Consider the following code block:
 
public class Person
{
    public string GetAge()
    {
        lock (this)
        {
            // Code to get Age of this person object.
        }
    }
}

Which of the following statements is true?
Answers:
• lock(this) actually modifies the object passed as a parameter, and in some way makes it read-only or inaccessible.
• lock(this) can be problematic if the instance can be accessed publicly, because code beyond one's control may lock on the object as well. This could create deadlock situations where two or more threads wait for the release of the same object.
• lock(this) marks current object as a critical section by obtaining the mutual-exclusion lock for a given object, all private fields of the object become read-only.
• Implement locking using current application instance or some private variable is absolutely the same and does not produce any synchronization issue, either technique can be used interchangeably.
36. The ___________ namespace is not defined in the .NET class library.
Answers:
• System
• System.CodeDom
• System.IO
• System.Thread
• System.Text
37. Which of the following is true about constructors and member functions?
Answers:
• A constructor can return values, but a member function cannot.
• A member function can declare and define values, but a constructor cannot.
• A member function can return values, but a constructor cannot.
• All of these.
38. Which of the following language code is not 'managed' by default in .NET framework?
Answers:
• Visual Basic
• C#
• C++
• Jscript
39. There is a class that has a public int counter field that is accessed by multiple threads. This int is only incremented or decremented. To increment this field, three thread-safe approaches are mentioned below:

A) lock(this.locker) this.counter++;
B) Interlocked.Increment(ref this.counter);
C) Change the access modifier of counter to public volatile

Which statement is incorrect with regards to these approaches?
Answers:
• All 3 are equivalent and can be used interchangeably.
• Though A is safe to do, it prevents any other threads from executing any other code which is guarded by locker.
• B is the best approach as it effectively does the read, increment, and write in 'one hit' which can't be interrupted.
• C on it's own isn't actually safe at all. The point of volatile is that multiple threads running on multiple CPU's can, and will, cache data and re-order instructions.
40. What will happen if the following code is compiled in .NET 4 or above (Assume required namespaces are included)?

public class var { }
public class main
{
    public static void main(string[] args)
    {
        var testVar = new var();
    }
}
Answers:
• This code will not compile, as var is a reserved keyword, so it can not be used as a class name.
• This code will compile, as var is merely a contextual keyword and it is used to provide a specific meaning in the code, so it will cause no problems.
• This code will not compile, as a new object cannot be created like var testVar = new var();
• None of these.
41. Which object oriented term is related to protecting data from access by unauthorized functions?
Answers:
• Inheritance
• Data hiding
• Polymorphism
• Operator overloading
• Abstraction
42. One of the ternary operators provided in C# is:
Answers:
• *
• ::
• &
• ?:
• &lt&lt
43. What type of code is written to avail the services provided by Common Language Runtime?
Answers:
• MSIL
• Unmanaged code
• Managed Code
• C#/VB/JS
44. Asynchronous execution is supported in ADO.NET 2.0 for?
Answers:
• ExecuteReader
• ExecuteScalar
• ExecuteNonQuery
• All of these
45. The .NET Framework consists of:
Answers:
• The Common Language Runtime
• A set of class libraries
• The Common Language Runtime and a set of class libraries
46. An enum is defined in a program as follows:
         [Flags]
        public enum Permissions
        {
            None = 0,
            Read = 1,
            Write = 2,
            Delete = 4
        }

What will be the output of the following Main program (which has access to the enum defined above) in this C# console application (Assume required namespaces are included) :

static void Main(string[] args)
{
    var permissions = Permissions.Read | Permissions.Write;
    if ((permissions & Permissions.Write) == Permissions.Write)
    {
        Console.WriteLine("Write");
    }
    if ((permissions & Permissions.Delete) == Permissions.Delete)
    {
        Console.WriteLine("Delete");
    }
    if ((permissions & Permissions.Read) == Permissions.Read)
    {
        Console.WriteLine("Read");
    }
    Console.ReadLine();
}
Answers:
• Write Delete Read
• Write Delete
• Delete
• Write Read
47. Which of the following keywords prevents a class from being overridden further?
Answers:
• abstract
• sealed
• final
• oot
• internal
48. Suppose a class is declared as a protected internal:
protected internal class A
{
}

Which statement is correct with regards to its accessibility?
Answers:
• This class can be accessed by code in the same assembly, or by any derived class in another assembly.
• This class can only be accessed by code which is in the same assembly.
• This class can only be accessed by code which is in the derived class (i.e. classes derived from Class A) and which are in the same assembly.
• This class can be accessed by any code whether in the same assembly or not.
49. Which of the following is the correct way to randomize a generic list of 75 numbers using C#?
Answers:
• Random random = new Random(); List<object> products= GetProducts(); products.OrderBy(product => random.Next(products.Count));
• Random random = new Random(); List<object> products= GetProducts(); products.Randomize(product => random.Next(products.Count));
• Random random = new Random(); List<object> products= GetProducts(); products.Randomize(products.Count);
• Random random = new Random(); List<object> products= GetProducts(); products.Reverse(product => random.Next(products.Count));
50. What will be the value of the result variable after these two statements?


int num1 = 10, num2 = 9;

int result = num1 & num2;
Answers:
• 1
• 8
• 9
• 10
• 11
• 109
51. What is the output of the following code:

class CCheck {

    public static void Main() {
        string str = @"E:\\RIL\\test.cs";
        Console.WriteLine(str);
    }
}
Answers:
• "E:\\RIL\\test.cs"
• E:\\RIL\\test.cs
• "E:\RIL\test.cs"
• The compiler will generate an error saying undefined symbol '@'.
52. What is the issue with the following function?

public string GetName(int iValue)
{
    string sValue = "0";
    switch (iValue)
    {
        case 1:
            sValue = iValue.ToString();
        case 2:
            sValue = iValue.ToString();
            break;
        default:
            sValue = "-1";
            break;
    }
    return sValue;
}
Answers:
• The code will not compile as there shouldn't be a break statement in the default case label.
• The code will compile but if case 1 is passed as the input parameter to the function, the code for case 2 will also execute (after the code for case 1), and so the wrong value may be returned.
• The code will compile and run without any issues.
• The code will not compile as there is no break statement in case 1.
53. What will be the output of the following Main program in a C# console application (Assume required namespaces are included):

static void Main(string[] args)
{
    for (int i = 0; i < 1; i++)
    {
        Console.WriteLine("No Error");
    }
    int A = i;
    Console.ReadLine();
}
Answers:
• No Error
• This program will throw a compilation error, "The name 'i' does not exist in the current context".
• The program will compile, but throw an error at runtime.
• None of these.
54. What is the difference between int and System.Int32 CLR types?
Answers:
• int represents a 16-bit integer while System.Int32 represents a 32-bit integer.
• int is just an alias for System.Int32, there is no difference between them.
• int represents a 64-bit integer while Int32 represents a 32-bit integer.
• None of these.
55. What will be the return value if the function fn is called with a value of 50 for the parameter var?

public int fn(int var)
{
    int retvar = var - (var / 10 * 5);
    return retvar;
}
Answers:
• 50
• 25
• 49
• Error message
• None of these
56. Which of the following code snippets converts an IEnumerable<string> into a string containing comma separated values?
Answers:
• public static string ConvertToString(IEnumerable<T> source) { return new List<T>(source).ToArray(); }
• public static string ConvertToString(IEnumerable<T> source) { return string.Join(",",source.ToArray()); }
• public static string ConvertToString(IEnumerable<T> source) { return source.ToString(); }
• public static string ConvertToString(IEnumerable<T> source) { return string.Join(source.ToArray()); }
57. Which of the following is true regarding a null and an empty collection in C#?
Answers:
• An empty collection and a null are both objects.
• An empty collection and a null both have the same meaning.
• Both an empty collection and a null do not refer to any object.
• An empty collection is an object while the null keyword is a literal.
58. Which of the following exceptions cannot be thrown by the Delete() function of the FileInfo class (ie. FileInfo.Delete())?
Answers:
• IOException
• SecurityException
• UnauthorizedAccessException
• InvalidOperationException
59. Which of the following statements are true regarding the ref and out parameters in C#?
Answers:
• A variable that is passed as an out parameter needs to be initialized, but the method using the out parameter does not need to set it to something.
• The out parameter can be used to return the values in the same variable passed as a parameter of the method. Any changes made to the parameter will be reflected in the variable.
• The ref keyword can only be used on one method parameter.
• The ref parameter is considered initially assigned by the callee. As such, the callee is not required to assign to the ref parameter before use. Ref parameters are passed both into and out of a method.
60. What is the difference between the String and StringBuilder class objects with respect to mutability?
Answers:
• String objects are mutable, while StringBuilder objects are immutable.
• String objects are immutable, while StringBuilder objects are mutable.
• There is no difference between them in this context, as both are immutable.
• There is no difference between them in this context, as both are mutable.
61. Which of the following code samples will create a comma separated list from IList<string> or IEnumerable<string>?
Answers:
• public static T[] ToArray(IEnumerable<T> source) { return new List<T>(source).ToArray(); } IEnumerable<string> strings = ...; string[] array = Helpers.ToArray(strings); string joined = string.Join(",", strings.ToArray()); string joined = string.Join(",", new List<string>(strings).ToArray());
• List<string> ls = new List<string>(); ls.Add("one"); ls.Add("two"); string type = string.Join(",", ls.ToArray());
• string commaSeparatedList = input.Aggregate((a, x) => a + ", " + x)
• public static string Join(this IEnumerable<string> source, string separator) { return string.Join(separator, source); }
62. What is the advantage of using IList<T> over List<T>?
Answers:
• IList<T> uses reflection, which is the most efficient way to process an object inside memory.
• IList<T> implements hashing to store objects in the collection; which produces optimum performance.
• Using IList<T> rather than List<T> allows the code to be more flexible. It can replace the implementation with any collection that implements IList<T> without breaking any calling code.
• IList<T> only allows immutable types to be stored inside the collection.
63. How can a single instance application be created in C#?
Answers:
• System.Threading.SingleInstance can be used to ensure that only one instance of a program can run at a time.
• System.Threading.Mutex can be used to ensure that only one instance of a program can run at a time.
• Locks can be used to force a C# application to launch a single instance at a time.
• C# applications cannot be restricted to a single instance.
64. Which of the following code samples will execute a command-line program in C# and return its STD OUT results?
Answers:
• System.Diagnostics.Process pProcess = new System.Diagnostics.Process(); pProcess.StartInfo.FileName = strCommand; pProcess.StartInfo.Arguments = strCommandParameters; pProcess.StartInfo.UseShellExecute = false; pProcess.StartInfo.RedirectStandardOutput = true; pProcess.Start(); string strOutput = pProcess.StandardOutput.ReadToEnd(); pProcess.WaitForExit();
• Process p = new Process(); p.StartInfo.UseShellExecute = true p.StartInfo.RedirectStandardOutput = false p.StartInfo.FileName = "YOURBATCHFILE.bat"; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit();
• System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("program_to_call.exe"); psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; System.Diagnostics.Process proc System.Diagnostics.Process.Start(psi);; System.IO.StreamReader myOutput = proc.StandardOutput; proc.WaitForExit(2000); if (proc.HasExited) { string output = myOutput.ReadToEnd(); }
• System.Diagnostics.Process pProcess = new System.Diagnostics.Process(); pProcess.StartInfo.FileName = strCommand; pProcess.StartInfo.Arguments = strCommandParameters; pProcess.StartInfo.UseShellExecute = false; pProcess.StartInfo.RedirectStandardOutput = true; pProcess.StartInfo.WorkingDirectory = strWorkingDirectory; pProcess.Start(); string strOutput = pProcess.StandardOutput.ReadToEnd(); pProcess.WaitForExit();
65. What is an Action delegate?
Answers:
• An Action is a delegate to a method, that takes zero, one or more input parameters, but does not return anything.
• An Action is a delegate to a method, that takes zero, one or more input parameters, but always returns a boolean value.
• An Action is a delegate to a method that takes one or more input parameters, but does not return anything.
• An Action is a delegate to a method that takes one or more input parameters, but always returns a boolean value.
66. What is the difference between Expression<Func<T>> and Func<T>?
Answers:
• There is no difference between the two.
• Func<T> denotes a delegate, while Expression<Func<T>> denotes a tree data structure for a lambda expression.
• Func<T> denotes a function with parameter of dynamic type, while Expression<Func<T>> denotes a lambda expression.
• None of these.
67. Which of the following statements is true about IEnumerable<T>?
Answers:
• IEnumerable<T> supports a Size property.
• IEnumerable<T> supports a Count() extension.
• IEnumerable<T> cannot be casted onto an ICollection<T>.
• IEnumerable<T> cannot be casted onto an IList<T>.
68. Which of the following statements is true about the System.Environment.NewLine property?
Answers:
• It's a string containing "\n" for non-Unix platforms.
• It's a string containing "\n" for Unix platforms.
• It's a string containing "\r\n" for non-Unix platforms.
• It's a string containing "\r\n" for Unix platforms.
69. An Interface represents which kind of relationship?
Answers:
• IS A
• HAS A
• CAN DO
• None of these
70. Why is it a bad practice to use iteration variables in lambda expressions?
Answers:
• Iteration variables can cause problems with accessing a modified closure.
• Iteration variables are passed by value, which produces unexpected results.
• Iteration variables are passed by reference, which produces unexpected results.
• It is perfectly valid to use iteration variables in lambda expressions.
71. Which of the following code samples will check if a file is in use?
Answers:
• protected virtual bool IsFileLocked(FileInfo file) { FileStream stream = null; try { stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); } catch (IOException) { return true; } finally { if (stream != null) stream.Close(); } return false; }
• try { using (Stream stream = new FileStream("MyFilename.txt", FileMode.Open)) { } } catch { }
• internal static bool FileOrDirectoryExists(string name) { return (Directory.Exists(name) || File.Exists(name)) }
• FileInfo file = new FileInfo("file.txt"); if (file.Exists) { // TO DO }
72. Which of the following statements is true regarding the code samples below?

A: 
try {
  // code goes here
} catch (Exception e) {
  throw e; 
}

B:
try {
  // code goes here
} catch (Exception e) {
  throw; 
}
Answers:
• A will lose the call stack trace information. B will preserve the call stack trace information.
• A will preserve the call stack trace information. B will lose the call stack trace information.
• Both A and B will preserve the call stack trace information.
• Both A and B will lose the call stack trace information.
73. Which of the following is the correct way to implement deep copying of an object in C#?
Answers:
• By using the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter class.
• By using the System.Reflection.DeepCopy class.
• By using the DeepCopy() method of Object class.
• By using the MemberwiseClone() method of Object class.
74. What will be the output of the following Main program in a C# console application (Assume required namespaces are included)?

static void Main(string[] args)
{
    string Invalid = "$am$it$";
    string sResult = Invalid.Trim(new char[]{'$'});
    Console.WriteLine(sResult);
    Console.ReadLine();
}
Answers:
• amit
• am@am$
• $am$it$
• am$it
75. Which of the following is the correct way to perform a LINQ query on a DataTable object?
Answers:
• var results = from myRow in myDataTable where results.Field("RowNo") == 1 select results;
• var results = from myRow in myDataTable.AsEnumerable() where myRow.Field("RowNo") == 1 select myRow;
• var results = from myRow in myDataTable.Rows where myRow.Field<int>("RowNo") == 1 select myRow;
• var results = from myRow in myDataTable.AsEnumerable() where myRow.Field<int>("RowNo") == 1 select new { IID= myRow.Field<int>("IID"), Date = myRow.Field<DateTime>("Date"), };
76. What is the purpose of the vshost.exe file in Visual Studio?
Answers:
• It is used to improve the performance of the Visual Studio debugger.
• It is used to improve the performance of Visual Studio plugins.
• It is used to improve the performance of the C# compiler.
• It is used to load Visual Studio configuration data.
77. Which of the following code snippets for catch shows a better way of handling an exception?

1.
catch (Exception exc)
{
    throw exc;
}


2.
catch (Exception exc)
{
    throw;
}
Answers:
• 1 is better as it maintains the call stack.
• 2 is better as it maintains the call stack.
• Both are same.
• None of these.
78. What will be the value of result after these two statements?

    int num1 = 10, num2 = 9;
    int result = num1 ^ num2;
Answers:
• 1
• 8
• 9
• 10
• 3
• 1000000000
• 109
79. What will be the output of the following Main program in a C# console application (Assume required namespaces are included)?
static void Main(string[] args)
        {
            string sPrint = String.Format("{{ My name is bond. }}");
            Console.WriteLine(sPrint);
            Console.ReadLine();
        }
Answers:
• {{ My name is bond. }}
• It will throw a compilation error.
• { My name is bond. }
• It will throw a runtime error.
80. What is the difference between data types "System.String"  and "string" in C#?
Answers:
• string is a value type, while System.String is a reference type.
• There is no difference,string is just an alias of the System.String data type.
• string variable is limited to storing alphabetic characters, while System.String does not have any limit.
• None of these.
81. Which of the following is the correct code to close all references to the com objects below?

Workbooks books = excel.WorkBooks;
Workbook book = books[1];
Sheets sheets = book.WorkSheets;
Worksheet ws = sheets[1];
Answers:
• Marshal.ReleaseComObject(books);
• Marshal.FinalReleaseComObject(books);
• Marshal.ReleaseComObject(sheets); Marshal.ReleaseComObject(books);
• Marshal.ReleaseComObject(sheet); Marshal.ReleaseComObject(sheets); Marshal.ReleaseComObject(book); Marshal.ReleaseComObject(books);
82. Which of the following is the correct way to sort a C# dictionary by value?
Answers:
• List<KeyValuePair<string, string>> myList = aDictionary.ToList(); myList.Sort( delegate(KeyValuePair<string, string> firstPair, KeyValuePair<string, string> nextPair) { return firstPair.Value.CompareTo(nextPair.Value); } );
• List<KeyValuePair<string, string>> myList = aDictionary.ToList(); myList.Sort((firstPair,nextPair) => { return firstPair.Value.CompareTo(nextPair.Value); } );
• foreach (KeyValuePair<string,int> item in keywordCounts.OrderBy(key=> key.Value)) { // do something with item.Key and item.Value }
• var ordered = dict.OrderBy(x => x.Value);

Android Programming Test 2016

1. Which of the following are UI elements that you can use in a window in an Android application?
Answers:
• TextBox
• TextView
• TextField
• TextElement
• EditText
• RichText

2. What is the correct way to fix if checking the status of the GPS_PROVIDER throws SecurityException?
Answers:
• request permission for ACCESS_COARSE_LOCATION
• request permission for ACCESS_FINE_LOCATION
• request permission for INSTALL_LOCATION_PROVIDER
• None of the above
3. Which of the following is not Content Provider?
Answers:
• Contacts
• Contacts
• Shared Preferences
• MediaStore
• Bookmarks
• Settings
4. Which of the following statements are correct with regards to signing applications?

a) All applications must be signed.
b) No certificate authority is needed.
c) When releasing application special debug key that is created by the Android SDK build tools can be used.
Answers:
• a) and b) are true
• a) and c) are true
• b) and c) are true
• all statements are true
5. What does the following code do?

SensorManager mgr = (SensorManager) getSystemService(SENSOR_SERVICE);
List<Sensor> sensors = mgr.getSensorList(Sensor.TYPE_ALL);
for (Sensor sensor : sensors) {
        System.out.println(""+sensor.getName());
}
Answers:
• prints names of all available sensors in device
• prints names of all available sensor types in device
• prints names of all sensors which are not available
• none of above
6. What does the following code do?

try {
    String token = GoogleAuthUtil.getToken(this, email, "https://www.googleapis.com/auth/devstorage.read_only");
    System.out.println(token);
} catch (IOException e) {
    System.out.println("IOException");
} catch (UserRecoverableAuthException e) {
    System.out.println("UserRecoverableAuthException");
} catch (GoogleAuthException e) {
    System.out.println("GoogleAuthException"); 
}
Answers:
• prints token
• prints IOException
• prints UserRecoverableAuthException
• prints GoogleAuthException
7. Which of the following is correct to use for data transfer regularly and efficiently, but not instantaneously?
Answers:
• AsyncTask
• IntentService
• Sync adapters
• All of these
8. What is the ListActivity class used for?
Answers:
• Create a view to display a list of items from a data source.
• List all the activities currently running on the Android device.
• List all the activites that are installed on the Android device.
• List the activities whose IntentFilters match with a particular Intent type.
9. Using a content provider, which of the following operations are able to perform?
a) create 
b) read
c) update
d) delete
Answers:
• a, b and c
• b, c and d
• all of these
• none of these
10. Which of the following widgets helps to embed images in activities?
Answers:
• ImageView
• ImageButton
• both of above
• none of these
11. What is the best way of opening camera as sub-activity?
Answers:
• Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivity(takePictureIntent);
• Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, 1); }
• Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(takePictureIntent, 1);
• Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, -1); }
12. What is the correct way to restrict app visibility on Google Play to devices that have a camera?
Answers:
• <uses-feature android:name="android.hardware.camera"/>
• <uses-feature android:name="android.hardware.camera" android:required="true" />
• <uses-feature android:name="android.hardware.camera.front" android:required="true" />
• <uses-permission android:name="android.permission.CAMERA"/>
13. Which of the following sensors is only hardware-based?
Answers:
• linear acceleration sensor
• gravity sensor
• rotation vector sensor
• accelerometer sensor
14. Which of the following formats is not supported in Android?
Answers:
• MP4
• MPEG
• AVI
• MIDI
15. Which of the following permissions and configurations must be added in manifest file for implementing GCM Client?

A) com.google.android.c2dm.permission.RECEIVE
B) android.permission.INTERNET
C) android.permission.GET_ACCOUNTS
D) android.permission.WAKE_LOCK
E) applicationPackage + ".permission.C2D_MESSAGE"
F) A receiver for com.google.android.c2dm.intent.RECEIVE, with the category set as applicationPackage. The receiver should require the com.google.android.c2dm.SEND permission
Answers:
• A, B, C and D
• C, D, E and F
• A, B, E and F
• all of these
16. Which of the following permissons is needed to perform the network operations through internet?
a) INTERNET
b) ACCESS_NETWORK_STATE
Answers:
• a
• b
• both
• none
17. Consider the following snippet of code:

@Override
protected void onStop
{
Super.onStop();
SharedPreferences setting = getSharedPreferences("MyPrefs", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("MyBool", true);

<some more code here>
}

Which of the following should be used <some more code here>?
Answers:
• editor.save(); editor.close();
• editor.save(); editor.finish();
• editor.commit();
• editor.save();
• editor.close();
• editor.finish();
18. What does the following statement define?

It provides query(), insert(), update(), and delete() methods for accessing data from a content provider and invokes identically-named methods on an instance of a concrete content provider.
Answers:
• CursorLoader
• ContentResolver
• ContentProvider
• Loader
19. What is the advantage of using AsyncTaskLoader instead of AsyncTask?
Answers:
• a bit easier to work with
• the possibility easily update progress bar
• no comparison, because it implements completely different functionality
• less work with the configuration of application
20. What does the following code do?

public boolean isOnline() {
   ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
   return (networkInfo != null && networkInfo.isConnected());
}
Answers:
• checking Network connection.
• checking only WIFI network connectivity.
• checking only Bluetooth data connection.
• checking only Ethernet data connection
21. Which of the following statements are correct with regards to running of the Sync Adapter?

A) Running sync adapter in response to a user request.
B) Running sync adapter periodically by setting a period of time to wait between runs, or by running it at certain times of the day, or both.
Answers:
• Statement A is true, while Statement B is false.
• Statement B is true, while Statement A is false.
• Both statements are true.
• Both statements are false.
22. Which of the following statements are correct with regards to calling place GoogleAuthUtil.getToken()?
A) call getToken() on the UI thread
B) call getToken() on AsyncTask
Answers:
• Statement A is true, while Statement B is false.
• Statement B is true, while Statement A is false.
• Both statements are true.
• Both statements are false.
23. Which of the following protocols are provided by Google for GCM Connection Servers?
A) HTTP
B) XMPP
C) SOAP
D) RMI
Answers:
• A and B
• A, B, C
• C, D
• all of these
24. Which of the following 4 classes does not relate to others?

ApplicationInfo, SyncInfo, ActivityInfo, PackageInfo
Answers:
• ApplicationInfo
• SyncInfo
• ActivityInfo
• PackageInfo
25. Which of the following are valid ways to deploy an Android application to a device?
Answers:
• Using the "adb install /path/to/apk" command from the command prompt/terminal, when USB Debugging Mode is enabled in the device.
• Exporting and signing the package, then browsing it to install.
• Launching the application from an IDE, when USB Debugging Mode is enabled in the device.
• All of these.
26. Which of the following classes is not used in working with database?
Answers:
• SQLiteOpenHelper
• SQLiteDatabase
• ContentProvider
• DatabaseHelper
27. Consider the XML fragment below, which is taken from one of the files in an Android project:
<MyElement xmlns:"http://schemas.androd.com/apk/res/android"
        android:layout_width = "fill_parent"
        android:layout_height = "fill_parent"
        android:text = "Some Text">
</MyElement>
Which of the following are true about the XML fragment above?
Answers:
• It is taken from the manifest XML file of the Android project.
• It is taken from an XML file used to define a view.
• It is taken from the package file (.apk) of the Android project.
• The xmlns: attribute is a compulsory attribute.
• If this is not the outer most tag in the XML file then it need not contain the xmlns: attribute.
• MyElement should be the name of a class derived, directly or indirectly, from the View class.
28. Which of the following statement is correct regarding StrictMode?
Answers:
• StrictMode detects improper layouts
• StrictMode detects operation which blocks UI
• StrictMode detects the speed of the connection
• All of the above
29. Consider the code snippet below:
MediaPlayer mp = new MediaPlayer();

mp.setDataSource(PATH_TO_FILE);

<Some code here>

mp.start();
Which of the following should be placed at <Some code here>?
Answers:
• mp.prepare();
• mp.prepareAsync();
• mp.loadMedia();
• mp.loadSource();
• mp.loadSource(); mp.prepare();
• No code is required at <Some code here> to start playback.
30. Consider the code snippet below:


public class MyReceiver extends PhoneStateIntentReceiver

{


    @Override

    public void onReceiveIntent(Context context, Intent intent)


    {

        if (intent.action == Intent.CALL_ACTION)

        {


        }

    }

}


Assuming that notifyPhoneCallState has been called to enable MyReceiver to receive notifications about the phone call states, in which of the following cases will the code in get executed?
Answers:
• When the device receives an incoming phone call.
• When an outgoing phone call is initiated on the device.
• When the user presses the CALL button on the device.
• The code in will never get executed.
31. Which of the following are true about enabling/disabling menu items from an Activity class?
Answers:
• onCreateOptionsMenu can be used to enable/disable some menu items in an Android application.
• onPrepareOptionsMenu can be used to enable/disable some menu items in an Android application.
• onShowOptionsMenu can be used to enable/disable some menu items in an Android application.
• The menu items in an Android application cannot be disabled.
32. Which of the following should be used to save the unsaved data and release resources being used by an Android application?
Answers:
• Activity.onStop()
• Activity.onPause()
• Activity.onDestroy()
• Activity.onShutdown()
• Activity.onFreeze()
33. Which of the following statements are correct with regards to publishing updates of apps on Google Play?
Answers:
• The android:versionCode attribute in the manifest file must be incremented and the APK file must be signed with the same private key.
• The android:versionCode attribute in the manifest file must be same and the APK file must be signed with the same private key.
• The android:versionCode attribute in the manifest file must be incremented and the APK file must be signed with the new private key.
• The android:versionCode attribute in the manifest file must be same and the APK file must be signed with the new private key.
34. Which of the following would you have to include in your project to use the SimpleAdapter class?
Answers:
• import android.content;
• import android.widget;
• import android.database;
• import android.database.sqlite;
• import android.util;
35. Which of the following is/are appropriate for saving the state of an Android application?
Answers:
• Activity.onFreeze()
• Activity.onPause()
• Activity.onStop()
• Activity.onDestroy()
36. Which of the following is the parent class for the main application class in an Android application that has a user interface?
Answers:
• MIDLet
• AndroidApp
• Activity
• AppLet
• Application
37. Which of the following can be used to bind data from an SQL database to a ListView in an Android application?
Answers:
• SimpleCursor
• SimpleCursorAdapter
• SimpleAdapter
• SQLiteCursor
• SQLLiteAdapter
38. Consider the code snippet below:

MediaPlayer mp = new MediaPlayer();

mp.setDataSource(PATH_TO_FILE);

<Some code here>

mp.start();


Which of the following should be placed at <Some code here>?
Answers:
• mp.prepare();
• mp.prepareAsync();
• mp.loadMedia();
• mp.loadSource();
• mp.loadSource(); mp.prepare();
• No code is required at <Some code here> to start playback.
39. Which of the following packages provide the classes required to manage the Bluetooth functionality on an Android device?
Answers:
• android.hardware
• android.bluetooth
• android.bluez
• org.bluez
40. Which of the following can be accomplished by using the TelephoneNumberUtil class?
Answers:
• Save a phone number to the contacts in the phone device.
• Retrieve a phone number from the contacts in the phone device.
• Delete a phone number from the contacts in the phone device.
• Format an international telephone number.
• Setting and retrieving the call forwarding phone number on the phone device.
41. Which of the following is the best way to request user permission if an Android application receives location updates from both NETWORK_PROVIDER and GPS_PROVIDER?
Answers:
• Adding this line to the Android manifest file: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
• Adding these two lines to the Android manifest file: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
• Adding this line to the Android manifest file: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
• Adding this line to the Android manifest file: <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
42. Which of the following are true about PhoneStateIntentReceiver.notifyPhoneCallState?
Answers:
• notifyPhoneCallState has to be called if your application wishes to receive a notification about an incoming phone call.
• notifyPhoneCallState is a call back function that is called when the call state changes.
• notifyPhoneCallState is called to initiate a call from the device.
• notifyPhoneCallState is used to send notifications about call states.
• notifyPhoneCallState gets called when the device receives an incoming phone call.
43. Which of the following statements are correct with regards to Content Providers?

A) A content provider allows applications to access data.
B) A content provider must be declared in the AndroidManifest.xml file.
Answers:
• Statement A is true, while Statement B is false.
• Statement B is true, while Statement A is false.
• Both statements are true.
• Both statements are false.
44. Which of the following functions will return all available Content Providers?
Answers:
• List<ProviderInfo> returnList = new ArrayList<ProvderInfo>(); for (PackageInfo pack : getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS)) { ProviderInfo[] providers = pack.providers; if (providers != null) { returnList.addAll(Arrays.asList(providers)); } } return returnList;
• return getContext().getPackageManager().queryContentProviders("com.google", Process.myUid(), 0);
• List<ActivityInfo> returnList = new ArrayList<ActivityInfo>(); for (PackageInfo pack : getPackageManager().getInstalledPackages(PackageManager.GET_RECEIVERS)) { ActivityInfo[] providers = pack.receivers; if (providers != null) { returnList.addAll(Arrays.asList(providers)); } } return returnList;
• None of these.
45. What is the purpose of the ContentProvider class?
Answers:
• To play rich media content files.
• To create and publish rich media files.
• To share data between Android applications.
• To access the global information about an application environment.
• To maintain global application state.
46. Which of the following are true?
Answers:
• Both startActivity and startSubActivity start an activity synchronously.
• Both startActivity and startActivityForResults start an activity asynchronously.
• startActivity is an asynchronous call, but startSubActivity is synchronous.
• startActivity is a synchronous call, but startSubActivity is asynchronous.
47. Which of the following is the immediate base class for Activity and Service classes?
Answers:
• Application
• ApplicationContext
• Context
• Component
• Object
48. Which of the following are classes that can be used to handle the Bluetooth functionality on a device?
Answers:
• Adapte
• Manage
• Matche
• BluetoothAdapte
49. How many expansion files can an APK file have? Select all correct options.
Answers:
• one
• two
• three
• four
50. Which of the following are Android build modes?
Answers:
• Debug mode
• Release mode
• Production mode
• Development mode
51. What is "Android-dx"?
Answers:
• A command line tool to create Android project files.
• A framework to create unit tests for Android projects.
• A resource editor to create user interface for Android applications.
• A tool to generate Android byte code from .class files.
• An emulator to execute and debug Android projects.
52. Consider the XML fragment below, which is taken from one of the files in an Android project:

<MyElement xmlns:"http://schemas.androd.com/apk/res/android"

        android:layout_width = "fill_parent"

        android:layout_height = "fill_parent"

        android:text = "Some Text">

</MyElement>

Which of the following are true about the XML fragment above?
Answers:
• It is taken from the manifest xml file of the Android project.
• It is taken from an XML file used to define a view.
• It is taken from the package file (.apk) of the Android project.
• The xmlns: attribute is a compulsory attribute.
• If this is not the outer most tag in the XML file then it need not contain the xmlns: attribute.
• MyElement should be the name of a class derived, directly or indirectly, from the View class.
53. Which of the following fields of the Message class should be used to store custom message codes about the Message?
Answers:
• tag
• what
• arg1
• arg2
• userData
54. Suppose Screen1 is the main screen of an Android application MyAndroid. Now if another screen, Screen2 has to be opened from Screen1, then which of the following are true?
Answers:
• Screen2 has to be a part of MyAndroid.
• Screen2 can exist in any other Android application installed on the device.
• Screen2 will always be launched asynchronously.
• Screen2 can be launched synchronously.
• Screen2 can return a result code to Screen1 if launched with startActivity.
• Screen2 can return a result code to Screen1 if launched with startActivityForResult.
55. Select the two function calls that can be used to start a Service from your Android application?
Answers:
• bindService
• startService
• runService
• startActivity
56. Which of the following Integrated Development Environments can be used for developing software applications for the Android platform?
Answers:
• Android IDE
• Eclipse
• Visual Studio 2005
• Visual Studio 2008
57. Which of the following can you use to display an HTML web page in an Android application?
Answers:
• WebBrowser
• BrowserView
• WebView
• Browser
• HtmlView
58. Consider the following snippet of code:
<font size =2>
@Override
protected void onStop
{
Super.onStop();
SharedPreferences setting = getSharedPreferences("MyPrefs", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("MyBool", true);

<some more code here>
}

Which of the following should be used <some more code here>?
</font
Answers:
• editor.save(); editor.close();
• editor.save(); editor.finish();
• editor.commit();
• editor.save();
• editor.close();
• editor.finish();
59. What is "Android-Positron"?
Answers:
• A command line tool to create Android project files.
• A framework to create unit tests for Android projects.
• A resource editor to create user interface for Android applications.
• A tool to generate Android byte code from .class files.
• An emulator to execute and debug Android projects.
60. Which of the following can you use to add items to the screen menu?
Answers:
• Activity.onCreate
• Activity.onCreateOptionsMenu
• Constructor of the Activity class.
• Activity.onCreateMenu
• Activity.onStart
• Activity.onPrepareOptionsMenu
61. Which of the following is not a life-cycle methods of an Activity that can be implemented to perform various operations during the lifetime of an Activity?
Answers:
• onCreate
• onInit
• onCompleteThaw
• onRestart
62. What is the interface Spannable used for?
Answers:
• Manipulate text that can span across multiple pages.
• Manipulate text that can span across multiple TextView windows.
• This is the interface for text to which markup objects can be attached and detached.
• String parsing.
63. What is correct regarding GCM - Google Cloud Messaging service?
Answers:
• It does server to device communication.
• It does device to server communication.
• It does device to server communication and vice versa.
• It does device to device communication.
64. Which of the following procedures will get the package name of an APK file?
Answers:
• Looking for the package attribute's value of the <manifest> element in the manifest file.
• Executing the command, "pm list packages -f", in the ADB shell.
• Programmatically, using PackageManager in an installed Android app.
• Using the AAPT platform tool, "aapt dump badging apkName.apk".
65. What is the maximum supported file size for a single APK file (excluding expansion packages) in the Google Play Store?
Answers:
• 50MB
• 2GB
• 30MB
• unlimited
66. What is Android?
Answers:
• A new programming language that can be used to develop applications for mobile devices.
• A new IDE that can be used to develop applications for mobile devices.
• A software stack for mobile devices that includes an operating system, middleware and key applications.
• A new mobile device developed by Google.
67. Which of the following can be used to navigate between screens of different Android applications?
Answers:
• Binde
• Flow
• Navigate
• Intent
• ApplicationContext
68. Which of the following are valid features that you can request using requestWindowFeature?
Answers:
• FEATURE_NO_TITLE
• FEATURE_NO_ICON
• FEATURE_RIGHT_ICON
• FEATURE_NO_MENU
• FEATURE_TRANSPARENT_WINDOW
69. Which of the following are true?
Answers:
• startActivity and startActivityForResult can both be used to start a new activity from your activity class.
• Only startActivityForResult can be used to launch a new activity from your activity class.
• startActivity(myIntent); and startActivityForResult(myIntent, -1); have the same result.
• startActivity(myIntent); and startActivityForResult(myIntent, 0); have the same result.
• When startActivity is used to launch a new activity from your activity class then your activity class gets notified when the new activity is completed.
• When startActivityForResult is used to launch a new activity from your activity class then your activity class gets notified when the new activity is completed.
70. Which of the following can you use to display a progress bar in an Android application?
Answers:
• ProgressBa
• ProgressDialog
• ProgressItem
71. Which of the following can be used to handle commands from menu items in an Android application?
Answers:
• commandAction
• onMenuItem
• onMenuItemSelected
• onMenuItemClicked
• onOptionsItemSelected
72. Fill in the blank:

Once an app is published, the ________ cannot be changed. It should be unique for each APK.
Answers:
• private key
• package name
• main activity
• APK file name
73. Which of the following attributes in the manifest file defines version information of an application for the Google Play Store (as opposed to defining version information for display to users)?
Answers:
• android:versionCode
• android:versionName
• android:targetSdkVersion
• android:maxSdkVersion
74. Which of the following are true about Intent.CALL_ACTION and Intent.DIAL_ACTION?
Answers:
• Both of them are used to dial a phone number on the device.
• Intent.action == Intent.CALL_ACTION is true when a phone call is received on the device.
• Intent.action = Intent.CALL_ACTION is used when a phone number is to be dialled without showing a UI on the device.
• Intent.action = Intent.DIAL_ACTION is used when a phone number is to be dialled without showing a UI on the device.
• Intent.action = Intent.CALL_ACTION is used when a phone number is to be dialled without the user having to explicitly initiate the call.
• Intent.action = Intent.DIAL_ACTION is used when a phone number is to be dialled without the user having to explicitly initiate the call.
75. Suppose MyView is a class derived from View and mView is a variable of type MyView. Which of the following should be used to display mView when the Android application is started?
Answers:
• Call setCurrentView(mView) in the startApp() of the main application class.
• Call setContentView(mView) in the startApp() of the main application class.
• Call setContentView(mView) in the onStart() of the main application class.
• Call setContentView(mView) in the onCreate() of the main application class.
76. Which of the following programming languages can be used to develop software applications for the Android platform?
Answers:
• Java
• C# with .NET Compact Framework for mobile devices.
• C programming language.
• Android programming language.
77. Which of the following would you have to include in your project to use the APIs and classes required to access the camera on the mobile device?
Answers:
• import android.drivers;
• import android.hardware.camera;
• import android.camera;
• import android.util;
• import android.hardware;
78. What is "Android-activityCreator"?
Answers:
• A command line tool to create Android project files.
• A framework to create unit tests for Android projects.
• A resource editor to create user interface for Android applications.
• A tool to generate Android byte code from .class files.
• An emulator to execute and debug Android projects.
79. What is the maximum supported size for a single expansion file in the Google Play Store?
Answers:
• 50MB
• 2GB
• 30MB
• unlimited
80. Which of the following tools can be used to reduce apk package size?
Answers:
• lint
• ProGuard
• zipalign
• etc1tool

Twitter Bootstrap Test

1.Which of the following are not Bootstrap plugins? Transition tocible Tooltip boilerplate 2.   Which type of trigger cannot be us...