Monday, March 21, 2011

iPhone/iPad Technical Interview Question(FAQ) with answers(Part 1)

Q1.What is the iPhone Application Entry point?
A. The main function:
int main(int argc, char *argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;

Q2.What is the GUI Entry Point?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    return YES;

Q3.What is the Model structure of iPhone Application?
@interface RootViewController : UITableViewController {
 NSArray *tableDataSource;

NSString *CurrentTitle;
NSInteger CurrentLevel;
IBOutlet UITableView * newsTable
UIActivityIndicatorView * activityIndicator
CGSize cellSize
NSMutableArray * stories
NSMutableDictionary * item;
NSString * currentElement
NSMutableString * currentTitle, * currentDate, * currentSummary, * currentLink

@property (nonatomic, retain) NSArray *tableDataSource;
@property (nonatomic, retain) NSString *CurrentTitle;
@property (nonatomic, readwrite) NSInteger CurrentLevel;

Q4.What is the View structure of iPhone Application?
@interface loancalculatorViewController : UIViewController {
IBOutlet UITextField *tbxLoanAmount;
IBOutlet UITextField *annualInterestRate;
IBOutlet UITextField *noOfYears;
IBOutlet UILabel *monthlyPayment;
IBOutlet UILabel *totalInterest;
IBOutlet UILabel *totalPayment;

@property (nonatomic,retain) UITextField *tbxLoanAmount;
@property (nonatomic,retain) UITextField *annualInterestRate;
@property (nonatomic,retain) UITextField *noOfYears;
@property (nonatomic,retain) UILabel *monthlyPayment;
@property (nonatomic,retain) UILabel *totalInterest;
@property (nonatomic,retain) UILabel *totalPayment;

Q5.What is the Controller structure of iPhone Application?

@interface RootViewController : UITableViewController {
mainView* myMainView;
- (id)init;
- (void)dealloc;
- (void)loadView;

Q6. What are Delegates in Objective-C?

A delegate allows one object to send messages to another object when an event happens.
A delegate is a pointer to an object with a set of methods the delegate-holder knows how to call. In other words, it's a mechanism to enable specific callbacks from a later-created object.

For example: when we create an object of UITableView like: UITableView *myTable;
then some methods like:


automatically called. These methods are called delegated.

Q7. What is the need of these Delegates?
 To execute some of must to do actions, we need these delegates.
For example: for a table it is must decided that, 
  • How many row will be there.
  • What will be the content on cell of each row.
  • What will happen after selecting the row.

Q8. How Memory Management is handle in iphone?

Q9. What is MVC ?
MVC (Model View Controller) is a design pattern used in services architectures. MVC separate the software architecture into three distinct elements. The 'Model' is how the underlying data is structured. The 'View' is what is presented to the user or consumer. The 'Controller' is the element that performs the processing. More.....

Q10.  MVC supports loose or tight coupling?
MVC supports both loose and tight coupling, because there is usually a tight coupling
between the view and the controller because user actions are difficult to interpret without details of the presentation. For example:
   • What object mouse clicked on 
   • What text area user typed into
Actions must be interpreted in terms of presentation
View has the information to map points in view to application objects

Refer the figure in this post.
•    View needs to know about model. Controller needs to know about model and view, So view and the controller are tightly coupled.
•    Model doesn’t need to know about either’s design, So Model loosely coupled to view/controller

All The Best :)

Next(Part 2)….