Skip to main content

Posts

Showing posts from April, 2009

Java Script Interview Questions

What's relationship between JavaScript and ECMAScript? - ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3. What are JavaScript types? - Number, String, Boolean, Function, Object, Null, Undefined. How do you convert numbers between different bases in JavaScript? - Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16); What does isNaN function do? - Return true if the argument is not a number. What is negative infinity? - It's a number in JavaScript, derived by dividing negative number by zero. What boolean operators does JavaScript support? - &&, and ! What does "1"+2+4 evaluate to? - Since 1 is a string, everything is a string, so the result is 124. How about 2+5+"8"? - Since 2 and 5 are integ

Job Interview Tips from Yahoo! HotJobs

Four Don'ts When Dealing With Recruiters Four Questions to Ask a Potential Manager How to Answer the Four Most Common Interview Questions How to Answer the Toughest Interview Questions How to Deal With Interview Stress How to Handle Illegal Interview Questions It's Your Turn: What to Ask an Interviewer Mastering the Informational Interview Minor Matters That Make Your Interview Phone Interviews: Tips to Get Called Back Surviving the Phone Screen The Second Interview The Waiting Game Turning the Tables on a Bad Interviewer What Not to Say in an Interview Worst-Case Scenario Survival Tactics for Job Seekers You Are What You Wear: Interview Attire Tips Mastering the Informational Interview Phone Interviews: Tips to Get Called Back Survival Tips for Group Interviews Surviving the Phone Screen Taking Your Show on the Road The Second Interview Why Do Employers Check Your Credit Report? Five Ways to Rescue a Dying Interview Four Don'ts When Dealing With Recr

PHP Interview Questions

1.What does a special set of tags <?= and ?> do in PHP? - The output is displayed directly to the browser. 2.What's the difference between include and require? - It's how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue. 3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what's the problem? - PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems. 4. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example? - In this example it wouldn't matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces. How

Perl Interview Questions

What arguments do you frequently use for the Perl interpreter and what do they mean? What does the command ‘use strict’ do and why should you use it? What do the symbols $ @ and % mean when prefixing a variable? What elements of the Perl language could you use to structure your code to allow for maximum re-use and maximum readability? What are the characteristics of a project that is well suited to Perl? Why do you program in Perl? Explain the difference between my and local. Explain the difference between use and require. What’s your favorite module and why? What is a hash? Write a simple (common) regular expression to match an IP address, e-mail address, city-state-zipcode combination. What purpose does each of the following serve: -w, strict, -T ? What is the difference between for & foreach, exec & system? Where do you go for Perl help? Name an instance where you used a CPAN module. How do you open a file for writing? How would you replace a char in string and how do you

How To Prepare For Interviews?

Starting Out, Again: When One Door Closes… - Losing a job for the first time can be an anxiety-laden milestone for twentysomethings. But it can also be an opportunity to rethink your course, and possibly make changes, before you've proceeded very far on a career path. Sharpen Your Aim When Job Hunting Online - As Internet job boards continue to evolve, it can pay to stay current on the latest search tools and tactics. By learning how to use them, job hunters may be able to boost their chances of securing interviews. Do's and Don'ts for Emailing Cover Letters and Resumes - Will employers frown on replying to job ads from my work email? Also, should I use the email itself as my cover letter or should I attach one? What is the best file format for attachments? Should I follow up with a hard copy? Ace Behavioral Interviews by Telling Powerful Stories - Behavior-based interviews have been around for more than a decade, but if you aren't prepared for them, they ca

XUL Tutorials & Resources

XUL Questions and Examples - This tutorial gives answers to the following questions. How do I hide and show a XUL element? How do I get the mouse position on a element? How do I get the content loaded in an iframe? How do I parse a string of XUL? -  How do I create a form and submit it? Is there a way to show a simple message box? How do I sort content? How do I retrieve and modify Mozilla preferences? How do I get the text of the currently selected item in a tree? How do I put arbitrary elements in a tree? How do I add an image to a treecell?  How do I add a progress meter to a treecell? Do I need to load XUL from the chrome directory? Is XUL security different than HTML? How do I load XUL from a Web site? How do I use a tree with RDF stored on a remote server?

MySQL tutorials

Using GROUP BY: SQL for MySQL Developers: A Comprehensive Tutorial and Reference - This excerpt from "SQL for MySQL Developers: A Comprehensive Tutorial and Reference" discusses adding aggregation functions to a select block with the use of a GROUP By clause. PHP+MySQL tutorial - This tutorial is our minor attempt to repay the general Internet community for all of the free software such as Linux, MySQL, Perl and PHP that we use on a day to day basis. By adding our two cents worth to the global bookshelf of knowledge that is the World Wide Web, we hope to keep the ball rolling. MySQL Basics - A Helpful MySQL Tutorial - This MySQL tutorial is a guide for new MySQL users, providing a reference of very basic, step by step, instructions on how to get started. This MySQL help page also gives more advanced users assistance in upgrading and running multiple versions of MySQL on a computer at the same time. MySQL is an SQL based relational database management system (DBMS) that run

Describe, in general, how java's garbage collector works?

The Java runtime environment deletes objects when it determines that they are no longer being used. This process is known as garbage collection. The Java runtime environment supports a garbage collector that periodically frees the memory used by objects that are no longer needed. The Java garbage collector is a mark-sweep garbage collector that scans Java's dynamic memory areas for objects, marking those that are referenced. After all possible paths to objects are investigated, those objects that are not marked (i.e. are not referenced) are known to be garbage and are collected. (A more complete description of our garbage collection algorithm might be "A compacting, mark-sweep collector with some conservative scanning".) The garbage collector runs synchronously when the system runs out of memory, or in response to a request from a Java program. Your Java program can ask the garbage collector to run at any time by calling System.gc(). The garbage collector requires abo

Types of JDBC Drivers

Java applications cannot directly communicate with a database to submit and retrieve the results of queries.this is because dbms/rdbms can understand only SQL statements and not java language statements .hence you need a mechanism to transalate java statements to SQL statements. JDBC API uses a driver to address these issues .JDBC API takes care of converting java commands to generic SQL statements . There are several categories of jdbc drivers provided by different database vendors .They are 1.JDBC-ODBC bridge driver:there are several DBMS/RDBMS, such as MS acess and SQL server that contain the ODBC driver embedded into them.since the ODBC API is written in the Clanguage and makes use of ponters and other constructs that java does not support ,a java program cannot directly communicate with an ODBC driver.The JDBC-ODBC bridge driver transalates the JDBC API to the ODBC API 2.Native API partly java driver: some DBMS/RDBMS,such as DB2and Informix,contail a JDBC driver supplied by th

J2ME Database Handling

I am developing a J2ME application and have no idea how to connect it with the database. I tried it doing, as given in some books but was unsuccessful. I included the following code in the constructor of MIDLET class String url = "jdbc:odbc:db1"; String userID = "cse1"; String password = "jss"; Statement DataRequest; ResultSet Results; Connection Db; try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver"); Db = DriverManager.getConnection(url,userID,password); } catch (ClassNotFoundException error) { System.err.println("Unable to load the JDBC/ODBC bridge." + error); System.exit(1); } catch (SQLException error) { System.err.println("Cannot connect to the database." + error); System.exit(2); } try { String query = "SELECT * FROM login"; DataRequest = Db.createStatement(); Results = DataRequest.executeQuery (query); //Place code here to interact with the ResultSet DataRequest.close(); } catch ( SQLException error ){ Syst

How do you pass parameters to a servlet from JSP

How do you pass parameters to a servlet from JSP? What kind of scope the JSP should have when we use forwardand backward button of the browser are used. 1) When you call a Servlet from a JSP by default JSP passes request and response objects to Servlet implicitly. So you canget all parameters in Servlet by usingrequest.getParameter("text1"); Why "String" is immutable in Java? 2) String is a immutable means youcan't change the value of a String object once it is intialized. Sincewhen you create a String it creates a String Object in Heap or Stringpool and assigns the reference of this object to a String variable. String str = new String("Java"); now Java is a object that iscreated in String pool. Once if you assign some String object to this"str" reference it is lost. When you are creating or adding some string value this String for eg. str =str.concat("Forum"); Here you are creating another

What is JUnit & How To Use It?

JunitPithy is built using Apache Ant and Ant has JUnit support as an optional package. With junit.jar in the classpath, Ant should automatically detect it, but where you want to keep your default classpath clean, which is my preference when you are trying to have a code tree with minimal external dependencies, the quickest way to enable it is to copy the junit.jar file into the $ANT_HOME/lib directory. With junit.jar in place, the Ant task <junit> is enabled. With that in place, we can organise the test classes. Rather than mix the test code with the actual code, it is better to have a separate test hierarchy with its own class tree. Here's the opening of build.xml: <project name="PithyDerby" default="compile" basedir="."> <property name="sourceDir" value="src" /> <property name="outputDir" value="bin" /> <property name="testDir" value="tests" /> <propert

Design Patterns in Java

What are the design patterns in Java? In j2ee they have 15 Design Pattern: Presentation Tier: 1.Intercepting Filter 2. Front Controller 3. View Helper 4. Composite View 5. Service to Worker 6. Dispatcher View Business Tier: 7. Business Delegate 8. Transfer Object 9. Session Facade 10. Service Locator 11. Transfer Object 12. Value List Handler 13. Composite Entity Integration Tier: 14.Service Activator 15 Data Access Object Programming idioms are more language specific than design patterns. A Design pattern is a documentation of a time-tested solution which keeps cropping up every now and then within a particular context. A Design Pattern is mostly not language specfic thought there could be a few design patterns which are language specific(I am not aware of any Java-specific design pattern). A design pattern encapsulates OO principles in a structure and if a Object-Oriented language provides support to these principles then you can use the design pattern in that language.

Does a class inherit the constructors of its superclass?

Constructors cannot be inherited, basically a constructor is not a method. Constructors are used to give a valid state for an object at creation. I am wondering what benefit it would be by inheriting constructors? If you have the answer them pls let me know. All you need to do is give an explicit call. Even if they are inherited how would you call the inherited constructor while creating the object? It would look like you are creating the object of superclassthough what you want is an object of the sub-class. You can get an idea of what I am telling by looking below. class A{ A(){ /*do something*/ } } class B extends A{ B(){ /*do something*/ } public static void main(String[] args){ A a = new A(); B b = new A();//is'nt this confusing? } B b = new A();--->Since your class B inherits the constructor of class A why not use it? Now I hope you see what happens if constructors are inherited. It is the responisiblity of the programmer to see to it that the variables of the superc

How we can use a class defined inside an interface?

public interface abc { static int i=0; void dd(); class a1 { a1() { int j; System.out.println("inside"); }; public static void main(String a1[]) { System.out.println("in interfia"); } } } A class is defined inside an interface to bind the interface to a TYPE. A small but nonsense example: interface employee{ class Role{ public String rollname; public int Role id; public Object person; } Role getRole(); // other methods } In the above interface you are binding the Role type strongly to the employee interface(employee.Role). One more reason is to have modifiable data within an interface(As you may know all fields in an interface are implicitly final). By declaring a class inside the interface you can have common MODIFIABLE data. public interface abc{ static int i=0; void dd(); class a1{ private int a1; int getA1(){ return a1; } int setA1(int a){ a1 = a; } } a1I

Is it possible to load more than one driver thru Class.forName() methode

Q1. Can we load more the one Driver thru Class.forName() method? Q2. What is the difference if we are using Class.forName()method and DriverManager.registerDriver(). Which one is better? You can load multiple drivers using the Class.forName() method. The drivers could be for the same database or for different databases. When you invoke Class.forName(), you, I mean the driver, are/is actually doing two things: 1) create an instance of the driver which is being loaded 2) register this instance of the driver with the DriverManager using the DriverManager.registerDriver() method. In order to use DriverManager.registerDriver you need a reference to a Driver instance. One way to get a reference to a driver instance is using the getDrivers method of the DriverManager class. But all the Driver instances you get by invoking this method are already registered with the Drivermanager, so this is of no use. The 'other way' is to create an instance of the Driver like this: Driver d = new or

Difference between response.sendRedirect() and request.forward()

sendRedirect() vs forward() sendRedirect() sends a redirect response back to the client's browser. The browser will normally interpret this response by initiating a new request to the redirect URL given in the response. forward() does not involve the client's browser. It just takes browser's current request, and hands it off to another servlet/jsp to handle. The client doesn't know that they're request is being handled by a different servlet/jsp than they originally called. There are different situations where you want to use one or the other. For example, if you want to hide the fact that you're handling the browser request with multiple servlets/jsp, and all of the servlets/jsp are in the same web application, use forward() or include(). If you want the browser to initiate a new request to a different servlet/jsp, or if the servlet/jsp you want to forward to is not in the same web application, use sendRedirect(). ****************************** The more si

Sample Coding in JDBC

Connecting to a Database This example uses the JDBC-ODBC bridge to connect to a database called ''mydatabase''. try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc: mydatabase "; Connection con = DriverManager.getConnection( url, "login" , "password" ); } catch (ClassNotFoundException e) { } catch (SQLException e) { } Creating a Table This example creates a table called ''mytable'' with three columns: COL_A which holds strings, COL_B which holds integers, and COL_C which holds floating point numbers. try { Statement stmt = con .createStatement(); stmt.executeUpdate("CREATE TABLE mytable ( COL_A VARCHAR(100), COL_B INTEGER, COL_C FLOAT) "); } catch (SQLException e) { } Entering a New Row into a Table This example enters a row containing a string, an integer, and a floating point number into the table called ''mytable''. try { Statement stmt = connec