Skip to main content

Posts

C# Interviews Questions

Amatya  Feel free to share information Email adityagupta200@gmail.com WhatsUp 09731764134 1. What is C#? C# is an object oriented, type safe and managed language that is compiled by .Net framework to generate  Microsoft  Intermediate Language. 2. What are the types of comment in C# with examples? i)Single line Eg  // Single Line ii. Multiple line (/* */) Eg: /* Amatya Balrampur */ iii. XML Comments (///) . Eg: /// XMLComments 3. Can multiple catch blocks be executed? No, Multiple catch blocks can’t be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed. 4. What is the difference between public, static and void? Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. The compiler stores th...

ANDROID TRAINING

10 AUGUST TO 31 AUGUST IN KORMANGLA,BANGALORE. Why Learn Android App Development? The inception of this flourishing Android phone market in 2008 also gave birth to the much-evolving Google play a.k.a the Android App Store. Much like the phone’s success, the app-store has shot off to astonishing levels too. Starting with around 2000 applications in 2008, Google Play now has more than 850,000 applications in store for its users. Moreover, it boasts of more than 48 billion downloads to date, with a download rate much faster than that of iOS (103 apps downloaded every second!). This app market has also opened wide doors to developers all around the world. With an open source concept, Android is free to develop on, prototype and deploy without paying a single cent in license fees. Android development is also much less restrictive as compared to its counter...
    Importing Classes and Packages The first two lines of the following listing import two classes used in the applet: Applet and Graphics . import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 25); } } If you removed the first two lines, the applet could still compile and run, but only if you changed the rest of the code like this: public class HelloWorld extends java.applet. Applet { public void paint( java.awt. Graphics g) { g.drawString("Hello world!", 50, 25); } } As you can see, importing the Applet and Graphics classes lets the program refer to them later without any prefixes. The java.applet. and java.awt. prefixes tell the compiler which packages it should search for the Applet and Graphics classes. Both the java.applet and java.awt packages are part of the core Java API -- API that every Ja...
    Consider the classic queuing problem, where one thread is producing some data and another is consuming it. To make the problem more interesting, suppose that the producer has to wait until the consumer is finished before it generates more data. In a polling system, the consumer would waste many CPU cycles while it waited for the producer to produce. Once the producer was finished, it would start polling, wasting more CPU cycles waiting for the consumer to finish, and so on. Clearly, this situation is undesirable. To avoid polling, Java includes an elegant interprocess communication mechanism via the following methods: wait( ): This method tells the calling thread to give up the monitor and go to sleep until some other thread enters the same monitor and calls notify( ). notify( ): This method wakes up the first thread that called wait( ) on the same object. notifyAll( ): This method wakes up all the threads that called wait( ) on the same ob...

::::INTERTHREAD COMMUNICATION::::

    Inter-Thread Communication        Java provides a very efficient way through which multiple-threads can communicate with each-other. This way reduces the CPU?s idle time i.e. A process where, a thread is paused running in its critical region and another thread is allowed to enter (or lock) in the same critical section to be executed.  This technique is known as Interthread communication which is implemented by some methods. These methods are defined in " java.lang " package and can only be called  within synchronized code shown as:  Method  Description  wait( )  It indicates the calling thread to give up the monitor and go to sleep until some other thread enters the same monitor and calls method notify() or notifyAll() .  notify( )  It wakes up the first thread that called wait() on the same object.  noti...

:::FANTASTIC EXP OF SCHRONIZATION:::::

          public class SynThread{ public static void main(String args[]){ Share s=new Share(); MyThread m1=new MyThread(s,"Thread1"); MyThread m2=new MyThread(s,"Thread2"); MyThread m3=new MyThread(s,"Thread3"); } } class MyThread extends Thread{ Share s; MyThread(Share s,String str){ super(str); this.s=s; start(); } public void run(){ s.doword(Thread.currentThread().getName()); } } class Share{ public synchronized void doword(String str){ for(int i=0;i<5;i++){ System.out.println("Started :"+str); try{ Thread.sleep(100); }catch(Exception e){} } } } Output of the program is: C:\j2se6\thread>javac SynThread.java C:\j2se6\thread>java SynThread Started :Thread1 Started :Thread1 Started :Thread1 Started :Thread1 Started :Thread1 Started :Thread3 Started :Thread3 Started :Thread3 Started...
Multithreading exploits the fact that most of the time the tasks (parts) of the same program are either waiting for the other resources to become free, or waiting for some timeout to occur. In the above example (spreadsheet), scroll operation is waiting for the calculation to be completed. If these parts or tasks can be described as independent threads, they can run individually and they don’t have to wait for the other threads to be completed. One can automatically switch from one task that is ready to wait to another task that is ready. In multithreading, two different tasks – performs calculations and scrolling, form two different threads. When the first thread performs calculation, the second thread can make the window scroll down. This would give the notion of both the operation being performed simultaneously to the user and improves the effectiveness of the application. Multithreading can be done in a single-processor or multiple processor environments. In a multiple processo...