Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Java Sample Questions ›› Core Java Sample Questions

Technical Sample Questions : Java Sample Questions : Core Java Sample Questions

  1. Explain the usage of Java packages.

    Answer: This is a way to organize files when a project consists of multiple modules.It also helps resolve naming conflicts when different packages have classes with the same names.Packages access level also allows you to protect data from being used by the non-authorized classes.

  2. If a class is located in a package, what do you need to change in the OS environment to be able to use it?

    Answer: You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable.Let's say a class Employee belongs to a package com.xyz.hr; and is located in the file c:\dev\com\xyz\hr\Employee.java.In this case, you'd need to add c:\dev to the variable CLASSPATH.If this class contains the method main(), you could test it from a command prompt window as follows: c:\>java com.xyz.hr.Employee

  3. What's the difference between J2SDK 1.5 and J2SDK 5.0?

    Answer: There's no difference, Sun Microsystems just re-branded this version.

  4. What would you use to compare two String variables - the operator == or the method equals()?

    Answer: I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.

  5. 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.

  6. Can an inner class declared inside of a method access local variables of this method?

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

  7. What can go wrong if you replace && with & in the following code: String a=null; if (a!=null && a.length()>10) {...}

    Answer: A single ampersand here would lead to a NullPointerException.

  8. What's the main difference between a Vector and an ArrayList

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

  9. When should the method invokeLater()be used?

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

  10. 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.

« Previous || Next »

Core Java Sample Question Number : 1-10| 11-20| 21-30| 31-40| 41-50| 51-60| 61-70| 71-80| 81-87|
Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.