Social Icons

twitterfacebookgoogle pluslinkedinrss feed

Friday, October 10, 2008

Huawei E220 modem on Ubuntu with Dialog HSDPA

Type following command in terminal

$ sudo wvdialconf /etc/wvdial.conf

$ sudo gedit /etc/wvdial.conf

uncomment the ‘Phone‘ field and give the phone number as *99***1# and save the file.

*Esc ---> shift qw and Enter for save in vim edit ($ sudo vim /etc/wvdial.conf )

install the following files and add the huawei driver. Drivers

$ tar xjvf huawei.tar.bz2
$ cd huawei
$ su
$ make info
continue installation acoding to info file..

Install conection software using following .deb file Software

If you want to monitor network usage following package... Package

more info: Visit

Wednesday, October 08, 2008

Java Location API

Here is Example Java Location API example. But work for this want to support Java Location API in UR mobile and inbuilt GPS receiver(I only test with mobile emulator).

what is Location API:

The Java Location API for J2ME is intended to run on small client devices such as mobile phones.The Location API object model consists of 11 classes and two listener interfaces (LocationListener and ProximityListener), all in the javax.microedition.location package. Their design approach uses several standard patterns—Facade, Factory Method, Singleton, and Value Object, and standard JavaBeans-style accessors. Of the 11 classes, two are Exception classes (LocationException and LandmarkException) and another four (AddressInfo, Criteria, Orientation, and QualifiedCoordinates) are primarily value objects. Many of the properties of these objects may in practice be unavailable, depending on the location-finding technology implementing the API. Still, these properties anticipate likely future developments in mobile networks and devices and the level of location and context detail that they provide.

Example Code:
package com.test.location;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.*;

public class LocTest extends MIDlet implements CommandListener {

private Display display;
private Form form;
private Command cmdExit,  cmdOK;
private StringItem si;

public LocTest() {
display = Display.getDisplay(this);
form = new Form("Location Api test");
cmdExit = new Command("Exit", Command.EXIT, 5);
cmdOK = new Command("OK", Command.OK, 1);
si = new StringItem("Geo Location", "Click OK");

public void startApp() {

public void pauseApp() {

public void destroyApp(boolean flag) {

public void commandAction(Command c, Displayable d) {
if (c == cmdOK) {
Retriever ret = new Retriever(this);
} else if (c == cmdExit) {

public void displayString(String string) {

public class Retriever extends Thread {

private LocTest midlet;

public Retriever(LocTest midlet) {
this.midlet = midlet;

public void run() {
try {
} catch (Exception ex) {

public void checkLocation() throws Exception {
String string;
Location l;
LocationProvider lp;
Coordinates c;

Criteria cr = new Criteria();

lp = LocationProvider.getInstance(cr);
l = lp.getLocation(60);

c = l.getQualifiedCoordinates();
if (c != null) {
// Use coordinate information
double lat = c.getLatitude();
double lon = c.getLongitude();
string = "\nLatitude : " + lat + "\nLongitude : " + lon+ "\nSpeed(km/h): " + (l.getSpeed() *3.59999);
} else {
string = "Location API failed";

Wednesday, October 01, 2008

Java interview ask question

Question: Why Java does not support multiple inheritence ?
Answer: Java DOES support multiple inheritance via interface implementation.

Question:What is the difference between final, finally and finalize?
Answer: o final - declare constant
o finally - handles exception
o finalize - helps in garbage collection

Question: Where and how can you use a private constructor.
Answer: Private constructor can be used if you do not want any other class to instanstiate the object , the instantiation is done from a static public method, this method is used when dealing with the factory method pattern when the designer wants only one controller (fatory method ) to create the object.

Question: In System.out.println(),what is System,out and println,pls explain?
Answer: System is a predefined final class,out is a PrintStream object and println is a built-in overloaded method in the out object.

Question: What is meant by "Abstract Interface"?
Answer: First, an interface is abstract. That means you cannot have any implementation in an interface. All the methods declared in an interface are abstract methods or signatures of the methods.

Question: Can you make an instance of an abstract class? For example - java.util.Calender is an abstract class with a method getInstance() which returns an instance of the Calender class.
Answer: No! You cannot make an instance of an abstract class. An abstract class has to be sub-classed. If you have an abstract class and you want to use a method which has been implemented, you may need to subclass that abstract class, instantiate your subclass and then call that method.

Question: Why Java does not support pointers?
Answer: Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel easier to deal with reference types without pointers. This is why Java and C# shine.

Question: Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?

Answer: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

Question: Can an inner class declared inside of a method access local variables of this method?

Answer: It's possible if these variables are final.

Question: What's the main difference between a Vector and an ArrayList

Answer: Java Vector class is internally synchronized and ArrayList is not.

Question: When should the method invokeLater()be used?

Answer: This method is used to ensure that Swing components are updated through the event-dispatching thread.

Question: How can a subclass call a method or a constructor defined in a superclass?

Answer: Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor.

For senior-level developers:

Question: What's the difference between a queue and a stack?

Answer: Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule

Question: You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?

Answer: Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.

Question: What comes to mind when you hear about a young generation in Java?

Answer: Garbage collection.

Question: What comes to mind when someone mentions a shallow copy in Java?

Answer: Object cloning.

Question: If you're overriding the method equals() of an object, which other method you might also consider?

Answer: hashCode()

Question: You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList?

Answer: ArrayList

Question: How would you make a copy of an entire Java object with its state?

Answer: Have this class implement Cloneable interface and call its method clone().

Question: How can you minimize the need of garbage collection and make the memory use more effective?

Answer: Use object pooling and weak object references.

Question: There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?

Answer: If these classes are threads I'd consider notify() or notifyAll(). For regular classes you can use the Observer interface.

Question: What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it?
Answer: You do not need to specify any access level, and Java will use a default package access level .