Friday, September 24, 2010

Java Interview Questions basics : 1


Here are some questions that are normally asked in interviews for Java :

1. Which is the default package that is imported even if you don’t specify it explicitly?
Ans. java.lang

2. When you specify import java.package.*, does it import all the sub-packages inside it?
Ans. No, for importing them, you will need to add more import statements such as, import java.package.sub.* etc.

3. What is the concept of a package in Java, why do we need packages?
Ans. This is a feature by which you can manage your classes, and prevent class name collisions. Think of a situation when your application has 1000s of classes. Say, for a bank application, there can be a Credit Card account and a Debit Card Account. You need to have a class for Account. But, you cannot have two different classes with the same name. Putting the two accounts classes in different packages will allow you to have two classes with the same name which exist in different packages.

4. Is it an error to add a package more than once?
Ans. No, neither the compiler or the JVM will report any error. While executing, it will be imported only once, no matter how many times you import a package.

5. What is the difference between the following operations, equals() and == ?
Ans. == will only compare the references, i.e, if they are present in the same memory location, while equals() will compare the contents of the references. But the output of the equals() operator might not be as expected if the equals() method is overwritten in any class. It is imperative that whenever you overwrite the equals() method , you should also override the hashCode() method, if you want your classes to be used by some collection classes.

6. Which is the root class of all Java classes?
Ans. It is the java.lang.Object class.

7. Will there be a problem if the main method is not declared as static?
Ans. You will not get a compile time error, but at run time, it throws an error, “Main method not public”, since the JVM will look for a static main method to execute a program. The main method is the only entry point to a Java program.

8. I have an object of some type, how do I figure out it’s class?
Ans. If you want to get its class name, then object.getClass() will return the fully qualified Class name of that object. If you want to check if that object is a type of a specific class, you can use instanceOf keyword which will return a boolean value depending upon the match.

9. Can a constructor of a class be private?
Ans. Yes, but then, you cannot create an instance of such a class directly. This is done in building Singleton classes. Please refer to Singleton design pattern to know more.

10. Can a constructor return a value?
Ans. No, this will give a compiler error. You cannot even return a void.

11. Can a constructor be static?
Ans. No.

12. Are constructors inherited, i.e, can they be overwritten in a sub class?
Ans. No.

13. Can a constructor be declared as “native”?
Ans. No.

14. Can a constructor be synchronized?
Ans. No.

15. In Java, do we have Pass by Value or Pass by Reference?
Ans. Java doesn’t support pass by reference. Everything in Java is Pass by Value.

16. How can we restrict a class from being instantiated directly?
Ans. This can be done by either marking it as “Abstract” or making it’s constructor “private”.

17. What is the difference between J2SDK 1.5 and J2SDK 5?
Ans. No difference, they are the same, but SUN came up with a fancy name. It is widely referred to as “Java 5”.

18. A method doesn’t have an access specifier. Is this OK?
Ans. Yes, this method will now have default access, meaning within that package in which the class is defined

Wednesday, September 22, 2010

My E-space 4

Questions :
1. Name the inventor of the Lisp programming language who is also credited with coining the term ‘Artificial Intelligence'.
2. Tim Cook is the COO of…?
3. Which famous brand has launched ‘TheSmokingJacket.com', a site that contains no nudity but plenty of sex talk and jokes?
4. Name the famous American politician who has sparked off a Twitter meme by coining a new word ‘refudiate' in the tweet and drawing comparisons with Shakespeare?
5. Who is to buy off most of telecom giant Motorola's wireless network equipment business for about $1.2 billion?
6. Paul D. Ceglia recently attracted headlines by claiming to own 84 per cent of which happening site by citing a contract he signed with the latter's founder?
7. What is the ‘Gorilla Grip of Death'?
8. Name the American actor who held the patent that is the basis for the Wi-Fi, GPS and mobile communications that we use today.
9. Thomas Flowers designed the world's first programmable electronic computer. What was it called?
10. If it is Dennis Ritchie for C, then who is it for D?

Answers :
1. John McCarthy.
2. Apple
3. Playboy
4. Sarah Palin.
5. Nokia Siemens.
6. Facebook
7. The now problematic way of holding the Apple iPhone 4 that affects the antenna's performance.
8. Hedy Lamarr.
9. Colossus
10. Walter Bright.

Questions :
1. The first entirely Indian made Web browser announced recently is called…?
2. Which major, with a profit of $2.9 billion, recently achieved the best quarter results in the company's 42-year history?
3. According to Google's DoubleClick Ad Planner, which site tops the 1,000 most-visited sites on the Web?
4. Which tech major announced a major $100-million healthcare initiative recently?
5. Name the password-stealing Firefox add-on that Mozilla disabled recently after it had been downloaded 1,800 times.
6. The codename for the processor microarchitecture being developed by Intel as a planned successor to Nehalem is called…?
7. Who makes the product mentioned in the first question of this quiz?
8. In a novel marketing exercise, which brand launched a Facebook app that ‘whitens' your profile pic?
9. According to security analysis firm Sophos' recent annual list, if India is the World No. 2 in spam, which country takes the top spot?
10. The first message sent over the pioneering Arpanet was ‘login'. On which letter is the link said to have crashed?

Answers :
1. Epic
2. Intel
3. Facebook.com
4. IBM
5. Mozilla Sniffer.
6. Sandy Bridge.
7. Hidden Reflex.
8. Vaseline
9. US
10. G.

My E-space 3

Questions :
1. Thanks to 35 CPU-years of idle computer time from which tech giant have a team of researchers shown that when solving a Rubik's Cube, no position requires more than 20 moves?
2. Frash has been creating a buzz for some time among iPhone and iPad enthusiasts. What is it?
3. What historic ruling did the US Copyright Office give on July 26 as regards manufacturer's protection mechanisms?
4. Which two manufacturers supply the NAND flash RAM chips for the iPad?
5. Name the rendering engines used in Firefox and Internet Explorer.
6. According to the Gartner figures for worldwide mobile device sales for the second quarter of 2010, name the three makers with more than 10 per cent share.
7. Name the content focussed start-up with a beverage-sounding name, founded by a former Google AdSense exec Gokul Rajaram, which has been snapped up by FaceBook for $10 million.
8. What is Asus' upcoming tablet called?
9. Ivan Seidenberg is the CEO of…?
10. What is ‘Muro' unveiled recently?

Questions :
1. Name the conference held recently at Lake Tahoe in California, and addressed by people such as Bill Gates and Jeff Bezos, that branded itself as “a new way to look at the economic power of innovation”?
2. ‘Menlo' is the codename for…?
3. The head of which cyber-giant resigned recently following accusations of sexual harassment by a former marketing contractor to the company?
4. Charles Phillips is the President of…?
5. What is ‘Blackpad' that is expected to debut before the end of 2010?
6. Name the Japanese imaging major who is to introduce a mouse-calculator called ‘X Mark I Mouse'?
7. Who sold off social network Bebo, chat client ICQ and an investment in travel search site Kayak in the past quarter?
8. Name the site founded by PayPal co-founder Max Levchin that makes widgets that help people express themselves, bought by Google recently for $182 million.
9. Name Microsoft Live Labs' Web optimised visualisation technology that had its genesis under the name Sand Codex.
10. Name the Web site where one can view charity pledges made by billionaires such as Larry Ellison, Bill & Melinda Gates, Paul Allen, George Lucas and Pierre Omidyar, amongst others.


Answers :
1. Google, of course!
2. It's a new third-party tool that for jailbroken devices that adds Flash compatibility.
3. It said that jailbreaking any mobile device did violate federal copyright law.
4. Toshiba and Samsung.
5. Gecko and Trident.
6. Nokia, Samsung and LG.
7. Chai Labs.
8. Eee Pad.
9. Verizon.
10. It's a free, HTML5-based Web drawing tool from DeviantArt, the popular social network for artists.

Answers :
1. Techonomy.
2. Microsoft's upcoming touch-screen phone.
3. Hewlett-Packard's Mark Hurd.
4. Oracle.
5. Research In Motion's touch-screen tablet to take on Apple iPad.
6. Canon.
7. AOL.
8. Slide.
9. Seadragon.
10. http://givingpledge.org/

Tuesday, September 21, 2010

My E-space 2

Questions :
1. What does T9, the patented predictive text technology for mobile phones, stand for?
2. Name Google's new YouTube initiative that highlights some of the hottest searches on Google in the US.
3. Which tech pioneer is behind the firm Interval Licensing which recently sued giants such as Apple, Google, Facebook, Yahoo, AOL and others over patent claims?
4. Name the Indian founder and his service, which ‘was supposed to help deliver news to users based on their ‘social graph,” that has been taken over by Google.
5. Firefox Tab Candy, an ‘experimental way to organize, control and massage your Firefox tabs', has been rechristened as….?
6. Which Indian company has launched what it claims to be the world's slimmest 8GB USB flash drive that measures just 2.3mm thin?
7. In the context of the Indian Army, what is F-INSAS?
8. Name the Tata company in Pune engaged in research and development in the field of high-performance computing.
9. Who has launched India's first Hindi QWERTY keypad phone ‘Y-45'?
10. If Amazon has Kindle, which Indian company has ‘Wink'?

Questions :
1. Simple one to begin with. How much did Intel shell out for McAfee?
2. Facebook's new location-based platform is called…?
3. Munjal Shah is the co-founder and CEO of which start-up snapped up by Google recently?
4. Name the entertainer who detonated an armoured truck to smithereens in the Nevada desert to promote Zynga's ‘Mafia Wars: Las Vegas'.
5. Name Microsoft's handmade glider which was the tech-giant's entry in the annual Flugtag competition organised by Red Bull.
6. Name the e-reader technology that is based in part on the motion of a butterfly's wings and who is behind the venture?
7. If its iPad for Apple, for whom will it be Optimus?
8. Which was the first version of Internet Explorer to be directly included with Windows?
9. Who tops McAfee's annual list of most dangerous celebrity to search for in cyberspace?
10. Continuing with the above question, what is the most dangerous Web search term in the context of India?

Answers :
1. Text on 9 keys
2. Google Beat.
3. Paul Allen, co-founder of Microsoft.
4. Rohit Khare and ‘Angstro'.
5. Firefox Panorama.
6. Moser Baer.
7. It is a new tech-rich programme to modernise the infantry which will commence in 2012. F-INSAS stands for ‘Futuristic Infantry Soldier As a System'.
8. Computational Research Laboratories.
9. Wynncom.
10. EC Media.

Answers :
1. $7.68 billion.
2. Facebook Places.
3. Like.com
4. Snoop Dog.
5. Microsoft Windows Project Phoenix.
6. Mirasol from Qualcomm.
7. LG.
8. Internet Explorer 3.0.
9. Cameron Diaz.
10. Waptrick.