Thursday, July 21, 2016

Useful Cell C, FNB Connect, MTN, Telkom Mobile and Vodacom #'s

Cell C

Cell C Prepaid - Activate SIM =>
Cell C Prepaid - Balance Check => *101#
Cell C Prepaid - Block SIM =>
Cell C Prepaid - Customer Care => 140
Cell C Prepaid - Directory Enquiries => 146
Cell C Prepaid - Emergency => 112
Cell C Prepaid - Please Call Me => *111*cellnumber#
Cell C Prepaid - Recharge =>
Cell C Prepaid - Self Service (USSD) => *147#, option 3
Cell C Prepaid - Subscriber Details => *147*100#
Cell C Prepaid - Voicemail =>

FNB Connect

FNB Connect - Activate SIM => *147#
FNB Connect - Balance Check => *111#
FNB Connect - Block SIM => 147 or 087 575 0147
FNB Connect - Cellphone Banking => *120*321#
FNB Connect - Customer Care => 147 or 087 575 0147
FNB Connect - Directory Enquiries =>
FNB Connect - eWallet => *120*277#
FNB Connect - Emergency =>
FNB Connect - Please Call Me => *140*cellnumber#
FNB Connect - Recharge => *130*321#
FNB Connect - Self Service (USSD)       => *147#
FNB Connect - Subscriber Details =>
FNB Connect - Voicemail => 144

FNB Connect - APN Settings
Name                                   => FNB Connect
APN                                    => surf.fnbc.co.za
Username                             =>  enter in Username you received via SMS/Email when you provisioned your SIM card
Password                             => enter in Password you received via SMS/Email when you provisioned your SIM card
Authentication Type              => PAP

Save the changes.

More info https://www.fnb.co.za

MTN

MTN - Activate SIM =>
MTN - Balance Check =>
MTN - Block SIM =>
MTN - Customer Care => 173
MTN - Data Bundles => *141*2*9#
MTN - Detailed Balance => *136*1#
MTN - Internet Settings => *123#
MTN - Please Call Me =>
MTN - Recharge => *141*voucher number#
MTN - Self Service => *141*0#
MTN - Self Service (USSD) => *141*9#
MTN - Subscriber Details =>
MTN - Summary Balance => *141#

More info www.mtn.co.za, https://mycontract.mtn.co.za

Telkom Mobile

Telkom Mobile - Activate SIM =>
Telkom Mobile - Balance Check =>
Telkom Mobile - Block SIM =>
Telkom Mobile - Customer Care =>
Telkom Mobile - Data Bundles => *141*2*9#
Telkom Mobile - Detailed Balance => *141*1#
Telkom Mobile - Internet Settings => *123#
Telkom Mobile - Please Call Me =>
Telkom Mobile - Recharge =>
Telkom Mobile - Self Service (USSD) => *188#

More info http://www.telkommobile.co.za/login/

Vodacom

Vodacom - Activate SIM =>
Vodacom - Balance Check => *111#
Vodacom - Block SIM =>
Vodacom - Customer Care =>
Vodacom - Data Bundles =>
Vodacom - Detailed Balance =>
Vodacom - Internet Settings =>
Vodacom - Please Call Me =>
Vodacom - Recharge =>
Vodacom - Self Service (USSD) => *171#
Vodacom - Summary Balance => *171*9#

* Please note that if the option is blank or incorrect and you know the specific command, please leave a comment so I can update this blog post.

Tuesday, July 19, 2016

C# Interview Q's and A's


C#.NET interview questions and answers
Questions have been combined into one from the following links:
http://net-informations.com/faq/default.htm
http://a4academics.com/interview-questions/52-dot-net-interview-questions/417-c-oops-interview-questions-and-answers?showall=&limitstart=

http://www.c-sharpcorner.com/UploadFile/8ef97c/C-Sharp-net-interview-questions-and-answers/ https://www.toptal.com/c-sharp/interview-questions
http://career.guru99.com/top-50-c-sharp-interview-questions-answers/

1. What is C-Sharp (C#)?
C# is a type-safe, managed and object oriented language, which is compiled by the .NET framework for generating intermediate language (IL).

2. What is the Common Language Runtime (CLR)
The Common Language Runtime (CLR), the virtual machine component of Microsoft's .NET framework, manages the execution of .NET programs. A process known as just-in-time compilation converts compiled code into machine instructions which the computer's CPU then executes. The CLR provides additional services including memory management, type safety, exception handling, garbage collection, security and thread management. All programs written for the .NET framework, regardless of programming language, are executed by the CLR. All versions of the .NET framework include CLR.

3. What does Intermediate Language (IL) mean
Intermediate language (IL) is an object-oriented programming language designed to be used by compilers for the .NET Framework before static or dynamic compilation to machine code. The IL is used by the .NET Framework to generate machine-independent code as the output of compilation of the source code written in any .NET programming language.

IL is a stack-based assembly language that gets converted to bytecode during execution of a virtual machine. It is defined by the common language infrastructure (CLI) specification. As IL is used for automatic generation of compiled code, there is no need to learn its syntax.

This term is also known as Microsoft intermediate language (MSIL) or common intermediate language (CIL).

4. What is polymorphism
Polymorphism allows classes to be treated in a general manner, allowing the same method to act differently depending on context. So polymorphism is the ability (in programming) to present the same interface for differing underlying forms (data types).

5. What is composition
The use of references to objects of pre-existing classes as members of new objects is called composition (or aggregation). So basically the functionality of an object is made up of an aggregate of different classes. In practice, this means holding a pointer to another class to which work is deferred.

6. Explain the features of C#?
Below are some of the features supported in C# -
· Constructors and Destructors
· Properties
· Passing Parameters
· Arrays
· Main
· XML Documentation and
· Indexers

7. List some of the advantages of C#?
Below are the advantages of C# -
· Easy to learn
· Object oriented
· Component oriented
· Part of .NET framework

8. Explain the types of comments in C#?
Below are the types of comments in C# -
· Single Line Comment Eg : //
· Multiline Comments Eg: /* */
· XML Comments Eg : ///

9. Explain sealed class in C#?
A sealed class is used to prevent the class from being inherited from other classes. So “sealed” modifiers can also be used with methods to avoid the methods been overridden in the child classes.

10. Give an example of using sealed class in C#?
Below is the sample code of a sealed class in C# -


class X {}
sealed class Y : X {}


Sealed methods –


class A
{
protected virtual void First() { }
protected virtual void Second() { }
}
class B : A
{
sealed protected override void First() {}
protected override void Second() { }
}

If any class inherits from class “B” then the “First” method will not be over ridable as this method is sealed in class B.

11. List out the differences between Array and ArrayList in C#?
· Arrays store the values or elements of the same data type whereas ArrayList stores values of different datatypes.
· Arrays use a fixed length whereas ArrayList does not use a fixed length as in arrays.

12. Why use “using” in C#?
The “using” statement calls – the “dispose” method internally, whenever any exception occurs in any method call, and in the “using” statement objects are read only and cannot be reassign able or modifiable.

13. Explain namespaces in C#?
Namespaces are containers for the classes. We use namespaces to group related classes together in C#. The “using” keyword can be used to use the namespace in other namespace.

14. Why use the “const” keyword in C#? Give an example.
The “const” keyword is used to make an entity constant. We can’t reassign the value of a constant.

Eg: const string _name = "Test";

15. What is the difference between the “constant” and “readonly” variables in C#?
· The “const” keyword is used to make an entity constant. We cannot modify the value later in the code. Value assigning is mandatory to constant variables.
· A “readonly” variable value can be changed during runtime and the value to readonly variables can be assigned in the constructor or at the time of declaration.

16. Explain the “static” keyword in C#?
The “static” keyword can be used for declaring a static member. If the class is made static then all the members of that class are also static. If the variable is made static then it will have a single instance and the value change is updated in that instance.

17. What is the difference between the “dispose” and “finalize” variables in C#?
· Dispose - This method uses the “IDisposable” interface which frees up both managed and unmanaged codes like – database connection, files etc.
· Finalize - This method is called internally unlike the Dispose method which is called explicitly. It is called by the garbage collector and can’t be called from the code.

18. How is exception handling done in C#?
In C# a “try… catch” block is used to handle error and exceptions.

19. What is the difference between an abstract function and a virtual function?
An abstract function cannot have functionality. You're basically saying, any child class MUST give their own version of this method, however it's too general to even try to implement in the parent class.

A virtual function, is basically saying look, here's the functionality that may or may not be good enough for the child class. So if it is good enough, use this method, if not, then override me, and provide your own functionality.

20. Can we execute multiple catch blocks in C#?
No. Once an exception occurs it’ll execute that specific exception catch block and then control exits.

21. Why use the “finally” block in C#?
The “Finally” block will be executed irrespective of an exception occurring. So while executing the code in a try block and an exception occurs, control is passed to the catch block and at last the “finally” block will be executed. The “finally” block is used to close the connection to the database / releasing the file handlers can be kept in “finally” block.

22. What is the difference between the “finalize” and “finally” methods in C#?
· Finalize – This method is used for garbage collection. So before destroying an object this method is called as part of the clean-up process.
· Finally – This method is used for executing the code irrespective of if an exception occurred

23. What is the difference between “throw ex” and “throw” methods in C#?.
· “throw ex” will replace the stack trace of the exception with stack trace info of re throw point.
· “throw” will preserve the original stack trace info.

24. Can we have a “try” block without a “catch” block in C#?
Yes we can have a try block without a catch block.

25. List two different types of errors in C#?
Below are the types of errors in C# -
· Compile Time Error
· Run Time Error

26. Can we get an error while executing a “finally” block in C#?
Yes. We can get an error in the finally block.

27. Mention the assembly name where System namespace lies in C#?
Assembly Name – mscorlib.dll

28. What are the differences between static, public and void in C#?
· Static classes/methods/variables are accessible throughout the application without creating an instance. The compiler will store the method address as an entry point.
· Public methods or variables are accessible throughout the application.
· Void is used for the methods to indicate it will not return any value.

29. What is the difference between “out” and “ref” parameters in C#?
An “out” parameter can be passed to a method without it having to be initialized where as a “ref” parameter has to be initialized before it is used.

30. Explain Jagged Arrays in C#?
If the elements of an array is an array itself then it’s called a jagged array. The elements can be of different sizes and dimensions.

31. Can we use “this” inside a static method in C#?
No. We can’t use “this” inside a static method.

32. What are value types in C#?
Below are a list of value types in C# -
· struct
· datetime
· decimal
· int
· byte
· enum
· double
· long
· float

33. What are reference types in C#?
Below are a list of reference types in C# -
· class
· string
· interface
· object

34. Can we override private virtual method in C#?
No. We can’t override private virtual methods as it is not accessible outside the –class

35. Explain access modifier – “protected internal” in C#?
“protected internal” can be accessed by child classes as well as within the same assembly.

36. Will the finally block be executed if we add a return statement in the try block in C#?
Yes. Finally will always be executed regardless of whether a return statement has been added to the return statement.

37. What does inner exception mean in C#?
Inner exception is a property of the exception class which will give you more details of the exception i.e, the parent exception and child exception.

38. Explain String Builder class in C#?
This will represent the mutable string of characters and this class cannot be inherited. It allows us to Insert, Remove, Append and Replace the characters. “ToString()” method can be used for the final string obtained from StringBuilder. For example:

StringBuilder TestBuilder = new StringBuilder("Hello");
TestBuilder.Remove(2, 3); // result - "He"
TestBuilder.Insert(2, "lp"); // result - "Help"
TestBuilder.Replace('l', 'a'); // result - "Heap"

39. What is the difference between “StringBuilder” and “String” in C#?
· StringBuilder is mutable, which means once an object of stringbuilder is created, it can be modified later using Append, Remove or Replace.
· String is immutable which means we cannot modify the string object and a new object will always be create in memory.

40. What is the difference between methods – “System.Array.Clone()” and “System.Array.CopyTo()” in C#?
· “CopyTo()” method can be used to copy the elements of one array to another.
· “Clone()” method is used to create a new array to contain all the elements which are in the original array.

41. How can we sort the array elements in descending order in C#?
The “Sort()” method is used with “Reverse()” to sort the array in descending order.

42. Explain circular reference in C#?
A circular reference is a reference where multiple resources are dependent on each other which causes a lock condition that makes the resource unusable.

43. List out some of the exceptions in C#?
Below are some of the exceptions in C# -
· NullReferenceException
· ArgumentNullException
· DivideByZeroException
· IndexOutOfRangeException
· InvalidOperationException
· StackOverflowException etc.

44. Explain Generics in C#?
Generics in C# are used to make the code reusable which intern decreases the code redundancy and increases the performance and type safety.
Namespace – “System.Collections.Generic” is available in C# and this should be used over “System.Collections” types.

45. Explain object pool in C#?
Object pool is used to track the objects which are being used in the code. So object pool reduces the object creation overhead.

46. What does a delegate mean in C#?
Delegates are type safe pointers unlike function pointers in C++. A delegate is used to represent the reference of the methods of some return type and parameters.

47. What are the types of delegates in C#?
Below are the uses of delegates in C# -
· Single Delegate
· Multicast Delegate
· Generic Delegate

48. What are the three types of Generic delegates in C#?
Below are the three types of generic delegates in C# -
· Func
· Action
· Predicate

49. What are the differences between events and delegates in C#?
Main difference between event and delegate is event will provide one more of encapsulation over delegates. So when you are using events destination will listen to it but delegates are naked, which works in subscriber/destination model.

50. S.O.L.I.D: The First 5 Principles of Object Oriented Design
S.O.L.I.D is an acronym for the first five object-oriented design (OOD) principles by Robert C. Martin, popularly known as Uncle Bob.

S.O.L.I.D STANDS FOR:
When expanded the acronyms might seem complicated, but they are pretty simple to grasp.
· S – Single-responsibility principle
· O – Open-closed principle
· L – Liskov substitution principle
· I – Interface segregation principle
· D – Dependency Inversion Principle

For more information on the S.O.L.I.D principles visit S.O.L.I.D: The First 5 Principles of Object Oriented Design


ASP.NET MVC interview questions and answers Questions have been combined into one from the following links:

http://www.codeproject.com/Articles/556995/ASP-NET-MVC-interview-questions-with-answers http://a4academics.com/interview-questions/52-dot-net-interview-questions/713-asp-net-mvc?showall=&limitstart=

1. What is RenderBody?
In layout pages, renders the portion of a content page that is not within a named section. [MSDN]

2. What is RenderPage?
Renders the content of one page within another page. [MSDN] The page where you will place the content could be a layout or normal page.

3. What is RenderSection?
In layout pages, renders the content of a named section. [MSDN]

4. What is MVC?
MVC is a pattern which is used to split the application's implementation logic into three components: models, views, and controllers.

5. Can you explain Model, Controller and View in MVC?
· Model – It’s a business entity and it is used to represent the application data.
· Controller – Request sent by the user always scatters through controller and it’s responsibility is to redirect to the specific view using View() method.
· View – It’s the presentation layer of MVC.

6. Explain the new features added in version 4 of MVC (MVC4)?
Following are newly added features –
· Mobile templates
· Added ASP.NET Web API template for creating REST based services.
· Asynchronous controller task support.
· Bundling the java scripts.
· Segregating the configs for MVC routing, Web API, Bundle etc.

7. Can you explain the page life cycle of MVC?
Below are the processed followed in the sequence -
· App initialization
· Routing
· Instantiate and execute controller
· Locate and invoke controller action
· Instantiate and render view.

8. What are the advantages of MVC over ASP.NET?
· Provides a clean separation of concerns among UI (Presentation layer), model (Transfer objects/Domain Objects/Entities) and Business Logic (Controller).
· Easy to UNIT Test.
· Improved reusability of model and views. We can have multiple views which can point to the same model and vice versa.
· Improved structuring of the code.

9. What is Separation of Concerns in ASP.NET MVC?
It’s the process of breaking the program into various distinct features which overlaps in functionality as little as possible. MVC pattern concerns on separating the content from presentation and data-processing from content.

10. What is Razor View Engine?
Razor is the first major update to render HTML in MVC 3. Razor was designed specifically for view engine syntax. Main focus of this would be to simplify and code-focused templating for HTML generation. Below is the sample of using Razor:
@model MvcMusicStore.Models.Customer
@{ViewBag.Title = "Get Customers";}
<div class="cust"> <h3><em>@Model.CustomerName</em> </h3>

11. What is the meaning of Unobtrusive JavaScript?
This is a general term that conveys a general philosophy, similar to the term REST (Representational State Transfer). Unobtrusive JavaScript doesn't intermix JavaScript code in your page markup.
Eg : Instead of using events like onclick and onsubmit, the unobtrusive JavaScript attaches to elements by their ID or class based on the HTML5 data- attributes.

12. What is the use of ViewModel in MVC?
ViewModel is a plain class with properties, which is used to bind it to strongly typed views. ViewModel can have the validation rules defined for its properties using data annotations.

13. What is meant by Routing in MVC?
Routing is a pattern matching mechanism of incoming requests to the URL patterns which are registered in route tables. Class – “UrlRoutingModule” is used for the same process.

14. What are Actions in MVC?
Actions are the methods in Controller classes which are responsible for returning the view or json data. Action will mainly have return type – “ActionResult” and it will be invoked from method – “InvokeAction()” called by the controller.

15. What is Attribute Routing in MVC?
ASP.NET Web API supports this type of routing. This was introduced in MVC5. In this type of routing, attributes are being used to define the routes. This type of routing gives more control over classic URI Routing. Attribute Routing can be defined at controller level or at Action level like –
[Route(“{action = TestCategoryList}”)] - Controller Level
[Route(“customers/{TestCategoryId:int:min(10)}”)] - Action Level

16. How to enable Attribute Routing?
Just add the method – “MapMvcAttributeRoutes()” to enable attribute routing as shown below
public static void RegistearRoutes(RouteCollection routes)
{
routes.IgnoareRoute("{resource}.axd/{*pathInfo}");


//enabling attribute routing
routes.MapMvcAttributeRoutes();
//convention-based routing
routes.MapRoute
(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Customer", action = "GetCustomerList", id = UrlParameter.Optional }
);
}

17. Explain JSON Binding?
JavaScript Object Notation (JSON) binding support started from MVC3 onwards via the newJsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.

18. Explain Dependency Resolution?
Dependency Resolver was also introduced in MVC3 and it is greatly simplified the use of dependency injection in your applications. This turn to be easier and useful for decoupling the application components and making them easier to test and more configurable.

19. Explain Bundle.Config in MVC4?
"BundleConfig.cs" in MVC4 is used to register the bundles by the bundling and minification system. Many bundles are added by default including jQuery libraries like - jquery.validate, Modernizr, and default CSS references.

20. How route table has been created in ASP.NET MVC?
Method – “RegisterRoutes()” is used for registering the routes which will be added in “Application_Start()” method of global.asax file, which is fired when the application is loaded or started.

21. Which are the important namespaces used in MVC?
Below are the important namespaces used in MVC -
System.Web.Mvc
System.Web.Mvc.Ajax
System.Web.Mvc.Html
System.Web.Mvc.Async

22. What is ViewData?
ViewData contains the key, value dictionary pairs and is derived from class – “ViewDataDictionary“. In action methods we are setting the value for viewdata and in view the value will be fetched by typecasting.

23. What is the difference between ViewBag and ViewData in MVC?
ViewBag is a wrapper around ViewData, which allows to create dynamic properties. Advantages of viewbag over viewdata will be –
· In ViewBag there is no need to typecast the objects as in ViewData.
· ViewBag will take advantage of dynamic keyword which is introduced in version 4.0. But before using ViewBag we have to keep in mind that ViewBag is slower than ViewData.

24. Explain TempData in MVC?
TempData is again a key, value pair like ViewData. This is derived from “TempDataDictionary” class. TempData is used when the data is to be used in two consecutive requests, this could be between the actions or between the controllers. This requires typecasting in the view.

25. What are HTML Helpers in MVC?
· HTML Helpers are like controls in traditional web forms. But HTML helpers are more lightweight compared to web controls as it does not hold viewstate and events.
· HTML Helpers returns the HTML string which can be directly rendered to HTML page. Custom HTML Helpers also can be created by overriding “HtmlHelper” class.

26. What are AJAX Helpers in MVC?
AJAX Helpers are used to create AJAX enabled elements like as Ajax enabled forms and links which perform the request asynchronously and these are extension methods of the AJAXHelper class which exists in namespace - System.Web.Mvc.

27. What are the options that can be configured in AJAX helpers?
Below are the options in AJAX helpers –
· Url – This is the request URL.
· Confirm – This is used to specify the message which is to be displayed in confirm box.
· OnBegin – Javascript method name to be given here and this will be called before the AJAX request.
· OnComplete – Javascript method name to be given here and this will be called at the end of the AJAX request.
· OnSuccess - Javascript method name to be given here and this will be called when the AJAX request is successful.
· OnFailure - Javascript method name to be given here and this will be called when AJAX request has failed.
· UpdateTargetId – Target element which is populated from the action returning HTML.

28. What is Layout in MVC?
Layout pages are similar to master pages in traditional web forms. This is used to set the common look across multiple pages. In each child page we can find – /p>
@{
Layout = "~/Views/Shared/TestLayout1.cshtml";
}
This indicates child page uses TestLayout page as it’s master page.

29. Explain Sections is MVC?
Section are the part of HTML which is to be rendered in layout page. In Layout page we will use the below syntax for rendering the HTML –
@RenderSection("TestSection")
And in child pages we are defining these sections as shown below –
@section TestSection{
<h1>Test Content</h1>
}
If any child page does not have this section defined then error will be thrown so to avoid that we can render the HTML like this –
@RenderSection("TestSection", required: false)

30. Can you explain RenderBody and RenderPage in MVC?
RenderBody is like ContentPlaceHolder in web forms. This will exist in layout page and it will render the child pages/views. Layout page will have only one RenderBody() method. RenderPage also exists in Layout page and multiple RenderPage() can be there in Layout page.

31. What is ViewStart Page in MVC? This page is used to make sure common layout page will be used for multiple views. Code written in this file will be executed first when applic

GIMP 2.8.18 and GIMP 2.9.4 released

As of the 13th July 2016 you can now download GIMP 2.8.18 and GIMP 2.9.4.  In order to download this software please go to http://www.gimp.org/downloads/ for the stable 2.8.18 release and http://download.gimp.org/mirror/pub/gimp/v2.9/ for the development 2.9.4 release.

Also for unstable nightly builds please go to http://nightly.darkrefraction.com/gimp/.  Remember that this is free software and the developers work really hard to write professional software like the GIMP so please do consider donating towards this awesome free PhotoShop alternative.