Vous êtes sur la page 1sur 18

Java ==== How do you find out what Java VM runs on your computer?

% java -version How do you compile and run programs written in Java? javac nameofsource.java java nameofsource How do you run an applet in Java? appletviewer somehtmlfile.html How does the main function of a Java program look? public class SomeClass { public static int main(String[] args) { .... } } What is wrong in the following statements? javac nameofsource java nameofsource.class The compiler requires .java and the interpreter mustn't have the extension .clas s. How do you print a line in Java? System.out.println("some string here"); What are the 3 types of comments in Java? // single line /* */ multiline /** */ comments used by javadoc How do you declare variables? Just like in C++. What are the 8 primitive data types in Java? How many bits? byte(8), short(16), int(32), long(64), float(32), double(64), boolean(1), char(1 6) How do arrays work in Java? (2 types of initialization Just like in C++, but using [] instead of * int[] someintegerarray = {1,2,3,4,5,6,7,8,9,10}; someintegerarray= new int[10]; How do you copy arrays? use the arraycopymethod like this: arraycopy(Object src, int srcPos, Object dest, int destPos, int length) What class represents the character arrays? java.lang.String What operators are there in Java? Same as in C++. + also works for strings. >>> inserts 0 in the first position (> > insers a 1 or a 0 depending on the string)

How do you create a for-each loop in Java? for (sometype variable : somecollectionofsometype) { ... } How do you create a class? Same way as in C# (public, private or protected) What are the naming conventions in Java? Same as in Ruby for classes. Methods should have verbs as names. How are methods created? Same as C#. What is an overloaded method? A method with the same name as a previously declared method but with a different signature. How do you create a constructor for a class? Same as in C++. How do you pass an arbitrary number of parameters to a method? You use the last argument ParamType... params. The params is actually an array i n disguise. It has a length field. =============================================================== Suppose you have an object and a method takes that object as a parameter, and mo difies some of its fields. Will those fields remain modified after the method re turns? Yes. Object references are passed by value. Using that reference will modify the object. How do you create an object? Just like in C++. Classname obj = new Classname(params, of, the, constructor); What does this mean? How do you use it in a constructor? This refers to the current object. When used in a constructor, simply write: this(param1, param2), to invoke another constructor of the same class. For examp le: public class Rectangle { private int x, y; private int width, height; public Rectangle() { this(0, 0, 0, 0); } public Rectangle(int width, int height) { this(0, 0, width, height); } public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } ... }

What are the modifiers in java? What differences are there from C++? public, private and protected. Protected is also available within the package. W ithout a modifier it is available only within the package and within the class i tself. How do you add a private class variable of type integer called MyInteger? private static int MyInteger; What restrictions are there for class methods? Class methods cannot use this. Class methods cannot access instance methods and instance variables without an object reference. How do you create constant in Java? static final PI = 3.141692683589 What are the naming conventions for constants? CAPITAL_LETTERS_SEPARATED_BY_UNDERSCORES Give 3 methods to initialize class variables. 1) public static int myVar = 15; 2) static { // static initialization goes here inside the static block } 3) public static int myVar = returnSomeVar(); public static int returnSomeVar() { return 15; } When do you use static initialization blocks? When you need to do some smart initalization that does error handling and/or fil ls arrays What is the advantage of initializing a static variable with a static private me thod? You can reuse that code. What is the equivalent of static initalization blocks for instance variables? Initializer blocks (they do not use the static keyword before them). What is a final method? A method that cannot be overriden. E.g.: public final int... blablabla... What switches do you need to use assert? java -ea MyProgram How do you say that class A is a subclass of class B? class A extends B How do you specify which interfaces does class A inherit? class A implements I1, I2 How do you declare a package private class? You do not use an explicit modifier? What are the acceptable modifiers for an outer class? public or package private

What are the acceptable modifiers for an inner class? public, private, protected or package-private How do you create an iterator? Create an inner class with methods like increment, current, isLast, etc. What is a local inner class? A class within the body of a method. What is an anonymous inner class? A class within the body of a method without a name. When should enums be used? How do you define enums? They should be used when needing a set of constants. They are defined like in C# : public enum Days { MONDAY, TUESDAY...} How do you use enums? (definition and testing of values) SomeEnum myEnum; if (enum==MONDAY) ... Why are java enums so special? They are actually classes, inheriting from java.lang.Enum How do you iterate through the values of an enum? for (EnumType e : EnumType.values()) {...} How do you use constructors in an enum? public enum Planet { MERCURY (3.303e+23, 2.4397e6), VENUS (4.869e+24, 6.0518e6), EARTH (5.976e+24, 6.37814e6), MARS (6.421e+23, 3.3972e6), JUPITER (1.9e+27, 7.1492e7), SATURN (5.688e+26, 6.0268e7), URANUS (8.686e+25, 2.5559e7), NEPTUNE (1.024e+26, 2.4746e7); private final double mass; // in kilograms private final double radius; // in meters Planet(double mass, double radius) { this.mass = mass; this.radius = radius; } .... other function go here } What are the 3 uses for an annotation? Information for the compiler, Runtime processing and Compiler/deployment-time pr ocessing How do you define an annotation? Similar to an interface. How do you use an annotation without any elements? @annotation_name class/function follows here

How do you write an annotation with some elements? @annotation_name ( element1 = value1, element2 = value2 ) class/function_follows_here What happens if an annotation has only one element named "value"? You can use it like this: @annotation_name(x) where x is the value of the elemen t named "value". Suppose you have this kind of class: public class Generation3List extends Generation2List { // // // // // // Author: John Doe Date: 3/17/2002 Current revision: 6 Last modified: 4/12/2004 By: Jane Doe Reviewers: Alice, Bill, Cindy

// class code goes here } How would you redesign this using an annotation? Define the ClassPreamble annotation: @interface ClassPreamble { String author(); String date(); int currentRevision() default 1; String lastModified() default "N/A"; String lastModifiedBy() default "N/A"; String[] reviewers(); // Note use of array } Use the annotation like this: @ClassPreamble ( author = "John Doe", date = "3/17/2002", currentRevision = 6, lastModified = "4/12/2004", lastModifiedBy = "Jane Doe" reviewers = {"Alice", "Bob", "Cindy"} // Note array notation ) public class Generation3List extends Generation2List { // class code goes here } How do you make the information in Class preamble appear in the Javadoc generate d documentation? Use the @Documented annotation like this: @Documented @interface ClassPreamble { ... rest of code here Which are the three annotations provided by the language? @Deprecated, @Override and @SuppressWarnings

What is the effect of the @Deprecated annotation? How do you use it? The compiler issues a warning whenever a class/function marked as deprecated is used. It is used like this: // Javadoc comment follows /** * @deprecated * explanation of why it was deprecated */ @Deprecated static void deprecatedMethod() { } What is the effect of the @OVerride annotation? It says that a certain function overrides a method in a superclass. The compiler issues a warning if this is not done correctly. It is not required to use it, b ut it is recommended. What does @Suppress warnings do? How do you use it with multiple and single argu ments? It suppresses "unchecked" or "deprecation" warnings. It is used like this: @SuppressWarnings("deprecation") or @SuppressWarnings(("deprecation", "unchecked")) and then the method that issues warnings. Compile this program: interface Closable { void close(); } class File implements Closable { @Override public void close() { //... close this file... } } What happens? Can you explain why? The compiler generates an error complaining that File.close doesn't override any method from its superclass. This is because it is not overriding Closable.close , it is implementing it! How do you define an interface? Like a class, only it uses the word "interface" instead of "class". How do you implement an interface? public class Bla implements ISomeInterface { } How do you cast an object into another object type? type1 object1 = (type1)some_other_type_of_object; Can interfaces be extended? Yes How do you call the constructor of the superclass of a class? super(param1, param2, ...paramn); How do you call a method of the superclass? super.some_method(param1, param2, ..., paramn);

What is the first thing that the constructor of a subclass should do? Call the constructor of the superclass. Give 6 examples of methods inherited from the class Object. public final Class getClass() public string toString() public int hashCode() protected Object clone() public bool equals(Object obj) protected void finalize() What do you have to do to use the clone() method? You have to implement the Cloneable interface. What is the relationship between hashCode() and equals(). If two object are equals, they must have the same hashcode. How do you declare a class or method which cannot be extended / overridden? Using the keyword final. How do you create an abstract class? Using the keyword abstract. Write six subclasses of the class Number. Byte, Integer, Float, Double, Long, Short What are the 3 reasons for using a boxed type? 1) A method requires an Object. 2) Access to constants. 3) Access to functions related to numbers or strings. How do you get a short from an int? Using the method intValue(). How do you compare a Double with a Long? Using the method compareTo. How do you check if a Float is equal to a Byte? Using the method equals. How do you convert to and from strings? toString and parseInt What is the difference between parseInt and decode? decode also accepts octal and hexa. How do you make parseInt work like decode? Using a second argument which gives the radix. How do you write formatted output? Use the printf or format methods of a PrintStream object. Give an example of a PrintStream object. System.out What does %n do? It is a newline appropriate to the platform. Which package contains the PrintStream class?

java.io What class do you use for greater flexibility in formatting of numbers? java.text.DecimalFormat What arguments does the constructor of DecimalFormat have? The pattern string. How does the pattern # denotes a digit 0 denotes a digit or Decimals are rounded Any other characters string of DecimalFormat functions? a trailing zero up (except . or , ) are added as-is in the output string

How do you format a value with a DecimalFormat object ? String output = some_decimal_format_object.format(123213131231); How do you call sine, cosine and other mathematical functions in Java? You use the Math class. The methods of this class are all statical. Give 2 examples of constants and 6 examples of basic functions from the Math cla ss. Math.E Math.PI floor, ceil, abs, min, max, round Give 4 examples of exponential and logarithmic functions log, pow, exp, sqrt How do you generate a random number? Using Math.random() Give 5 examples of is... functions from the Character class. isWhiteSpace, isDigit, isLetter, isUpperCase, isLowerCase. Give 3 examples of to... functions from the Character class. toUpperCase, toLowerCase, toString How do you find the length of a string? Using the method length(). How do you convert a String object (or part of it) to an array of characters? Using the method getChars(index_start, index_stop, buffer, index_dest_begin). How do you concatenate strings? Using String.concat() or the + operator. How do you create a formatted string? Using the String.format method (very similar to sprintf). How do you find the position of a character in a string? Using the String.indexOf method. What is the reverse of String.indexOf? The String.charAt method. What are the two ways of getting a substring using the substring method? substring with one index returns a substring from that index till the end. With two indexes... same as in Python.

How can you split a String into substrings? Using the String.split(String regexp[, int maximum_size_of_array]) method. What is the difference between substring method and subSequence method? The subSequence method returns a CharacterSequence. What does the String.trim() method do? Returns a String without leading and trailing white spaces. How do you convert from a number to a String? Using the String.valueOf method. Give 6 methods for comparing strings. beginsWith endsWith equals, equalsIgnoreCase compareTo, compareToIgnoreCase matches regionMatches You would like something like a String object but modifiable. What class do you use? The java.lang.StringBuilder class. How do you find the length and capacity of a StringBuilder object? Can the capac ity be modified? Using the methods StringBuilder.length and StringBuilder.capacity. The capacity modifies according to the needs. What is the capacity of a StringBuilder created with the StringBuilder() constru ctor? 16 elements. How do you change the length or the capacity? Using the setLength and ensureCapacity methods. Give 7 methods that modify a StreamBuilder's content. append, insert, reverse, delete, deleteCharAt, replace, setCharAt. With insert and append, the data to be appended/inserted is first converted to a string. You have a program using threads. You need something like a StringBuilder. What do you use? java.lang.StringBuffer -> same thing with synchronized methods. What is the equivalent of templates in Java? Generics How do you define a generic in Java? public class SomeGenericClass <T> { ... } What is a parametrized type? It's an invocation of a generic type. How do you instantiate a generic? Box<Integer> integerBox = new Box<Integer>(); What are some naming conventions for the type parameter?

E - element K - key T - type N - number V - value S, U, V - 2nd, 3rd, 4th parameter How do you define a generic method? Something like public static <U> void doSmth (U u) { .. How do you say that a certain generic method should only accept Number and Strin g types? public <U extends Number & String> void doBlaBla (param1, param2, ..) If Lion is subclass of Animal, does it mean that Box<Lion> inherits Box<Animal> ? No. What does Cage<? extends Animal> and Cage<? super Animal> mean? It means a type holding some type of animal or holding some type of object that is a superclass of Animal. Write a superclass of both Cage<Butterfly> and Cage<Lion> if Lion and Butterfly are of type Animal. Cage<? extends Animal> ... What good is the Cage<? extends Animal> type? You can write methods that iterate over a cage of some type of animal (Lion or B utterfly) and do stuff there. You cannot add animals to such a cage. What are types? classes, interfaces, enumerations, annotation types How do you add a class to a package? You add at the top of the source file: package package_name; How many classes are allowed in a source file? As many as you want but only ONE public class. How many package declarations are allowed in a source file? Only one. Suppose you have class Rectangle in package graphics. How do you include that me mber? import graphics.Rectangle; How do you import the public nested classes of graphics.Rectangle? import graphics.Rectangle.*; Suppose you have the statement import java.awt.* . Can you refer to java.awt.col or as just color? No. You need to import java.awt.color.* . What does static import mean? You only import the static members of a package like this: import static somepackage.*; What is the 'Catch or specify requirement' ? Code throwing exceptions must be enclosed in a try code that deals with the exce

ption OR a method that specifies that it can throw an exception. What are the three exception types? Checked exceptions (something like user errors), errors and runtime exceptions. The last two are called unchecked errors and derive from the Error and RuntimeEx ception classes. What are the 4 keywords relating to exceptions? try catch finally throw What objects can be used as arguments for the throw statement? Only those inherited from java.lang.Throwable. What are the most important subclasses of java.lang.Throwable? Error and Exception. Exception has the RuntimeException subclass. What is the naming convention for exceptions? They should end in Exception. Give example of 3 methods of StackTraceElement class. getLineNumber getFileName getMethodName Give example of a method of an Exception object. getStackTrace() ... returns an array of StackTraceElement. How do you use a log in Java? Use the java.util.logging package. How are 8 rules of naming for classes Buffered... -> buffered stream InputStream -> Input byte stream OutputStream -> Output byte stream Reader -> Input character stream Writer -> Output character stream PrintStream -> Formatted output using PrintWriter -> Formatted output using unctions) Scanner -> Scanner (for scanf type of Object... -> An object stream regarding streams in the java.io package?

bytes characters (these are for printf type of f functions)

What argument does the PrintWriter constructor have? A stream for writing characters in a file. What argument does the Scanner constructor have? A buffered stream for reading characters from a file. What are the important functions for the PrintStream and PrintWriter classes? format, print, println What are the important functions for the Scanner class? hasNext, next, nextDouble, hasNextDouble, etc. What are the equivalents of stdin, stdout and stderr in Java? System.in, System.out, System.err How can you use the console in Java without using the standard streams? Using the Console class.

How do you get the console using the Console class? System.console(); Give example of 3 methods of the Console object. readLine("Prompt :"); readPassword("Password :"); format(...); What are data streams used for? Writing and reading Java data types to What interfaces do data streams implement? The DataInput or the DataOutput interface. What are the most common data stream classes? java.io.DataInputStream and java.io.DataOutputStream. What is the role of the Serializable interface? Classes that implement this interface can be written to a file. What class is used for writing/reading objects? java.io.ObjectInputStream and java.io.ObjectOutputStream. What methods are used for reading/writing objects? readObject and writeObject of the appropriate stream objects. What are the interfaces implemented by ObjectInputStream and ObjectOutputStream and what are their superclasses? ObjectInput and ObjectOutput and the superclasses are DataInput and DataOutput. What does the java.io.File class represent? A file path and name, not a file. What can you do with a File object? Create it, find out if it exists, if it is readable, get its path, get its absol ute path, find out if it is writable or executable, if it is a file or directory , if it is hidden, the last date when it was modified, etc. What does the File.getParent() method do? Find out the parent of a file if a longer path (like "C:\Java\SDK\stuff.txt") is given. On Unix, the file separator is / and on Windows it is \. How do you write portab le programs? Using File.separator. What is the difference between the absolute path and canonical path? The absolute path might be C:\Java\..\Java\SDK\stuff.txt while the canonical pat h is simply C:\Java\SDK\stuff.txt (i.e. the simplest path possible). How do you find out the drives of a system? Using the File.listRoots. How do you seek through a file? Using the java.io.RandomAccessFile. What are the most important methods of RandomAccessFile (3) ? seek, skipBytes, getFilePointer Name three packages from java.util.

java.util.concurrent, java.util.logging, java.util.regex What are the important classes in the java.util.regex package? Pattern, Matcher and PatternSyntaxException. What return type has the main function in Java? void. How do you return a different return code to the OS (other than 0 = success) ? Using System.exit method. How do you make a constant in Java? final double myPI = 3.14; What important methods are in the Pattern class? Pattern.compile static method returns a pattern object containing the regex. Pattern.split method splits the string given as argument using the compiled rege x (of the object) as separator Pattern.matches static method checks quickly if the regex matches the second par am. Pattern.toString method returns the string representation of the method. How do you obtain a matcher object? You call the Pattern.matcher method with the argument the string to be matched. What is the Matcher object used for? start, end - Finding the index of the characters matched find, lookingAt, matches - Check if the pattern matches the string. replaceAll, replaceFirst, appendReplacement - Substitute the regexp with somethi ng else What is the difference between lookingAt and matches? matches checks if the entire string is matching the regex. lookingAt checks if the beginning of the regex is matching it. How do you create a thread? 1) Subclass java.lang.Thread (e.g.: myClass). Redefine the method run. Create a new object of the myClass type and call its start method. 2) Create a class (e.g.:myClass) that implements the Runnable interface. Define the method run. Create a new object of type Thread with the a new object of type myClass. Call its run() method. How do you do scanf in Java? Create a new Scanner object using the object System.in as argument. How do you pause execution? Using Thread.sleep. How do you interrupt a thread? Using myThread.interrupt() (where myThread is of type Thread). What does Thread.join() do? Waits until the specified thread finishes execution. What control structure exists in Java but is unavailable in C++? Labelled break (equivalent with a goto from within a loop). What classes are available for working with big numbers? BigInteger and BigDecimal.

How do you add, substract, divide or multiply big numbers? Using the methods BigInteger.add and BigInteger.multiply, etc. or their BigDecim al equivalents. How do you know if a Thread is still running? With the method isAlive(). What happens when a method is synchronized? Synchronized methods of an object cannot be accessed simultaneously. Essentially , it is as if the object had a mutex and before calling any synchronized method there is an acquire operation and a release after leaving it. How do you use synchronized statements? synchronize (some_object) { ...statements } How do you wake a thread that called wait()? Using the notify or notifyAll method. How do you use mutexes in Java? java.util.concurrent.locks.Lock ... use the ReentrantLock.tryLock() method. Reen trantLock is-a Lock. What interfaces are used for running tasks? Executor, ExecutorService and ScheduledExecutorService. What is the equivalent of Thread(someRunnableObject).start() on a executor? Executor.execute(someRunnableObject). What is the difference between ExecutorService and Executor interfaces? ExecutorServices has the submit() method which can call a Callable object AND a Runnable object How does a thread detect that an interrupt has ocurred? It either catches the interrupt exception, if the function is able to throw it O R it checks for interrupts with Thread.interrupted static method. What functions does ScheduledExecutorService interface support? submit() which specifies also the date at which a Runnable/Callable object shoul d be run. What is the difference between a Runnable and a Callable object? A Callable object returns a value. The submit function returns a Future object w hich can be used to retrieve the value returned by the Callable object. What class is used for managing properties? java.util.Properties What method do you use to load properties? Properties.load(someFileStream)... the file stream can be closed afterwards. Example: // create and load default properties Properties defaultProps = new Properties(); FileInputStream in = new FileInputStream("defaultProperties"); defaultProps.load(in); in.close(); // create application properties with default Properties applicationProps = new Properties(defaultProps);

// now load properties from last invocation in = new FileInputStream("appProperties"); applicationProps.load(in); in.close(); . . . How do you save properties? Using the Properties.load method. Example: FileOutputStream out = new FileOutputStream("appProperties"); applicationProps.store(out, "---No Comment---"); out.close(); What functions do you use to get a property? contains, containsKey, getProperty, getProperty(with default value), list, eleme nts, keys, size, etc. How do you set properties? setProperty, remove ( key) How do you get access to environment variables? Use the System.getenv() method. This returns a Map<String, String>. How do you get access to system properties? How do you set them? System.getProperty, System.setProperty Name some system properties. file.separator java.class.path java.home, java.vendor, java.version, line.separator, os.arch, os.name, os.versi on, path.separator, user.dir, user.home, user.name What is the equivalent of STL in Java? Java Collections Framework What is the basic interface hierarchy for Java Collections Framework? Collection - Set -- SortedSet - List - Queue Map - SortedMap How do you create an immutable set with only one element? Collections.singleton(someElement); What are some methods of collection (10)? add, addAll, remove, removeAll, contains, containsAll, retainAll, isEmpty, toArr ay, clear. What methods does an iterator provide (3)? hasNext, next and remove. What methods does contain Set over Collection? None new. No duplicates allowed.

What new methods are in List interface? get, set, indexOf, lastIndexOf, subList How do you get a list from an array? Using the static method Array.asList() which returns a List. What can you do with a list iterator? Go to next and previous elements, check if they exist, add, remove or set them. What are the important methods in the Queue interface? throw exception: add, remove, element return value: offer, poll, peek What are the basic operations of Map? put, get, containsKey, containsValue, size, isEmpty, clear, putAll What collections are there in a Map? keySet, values, entrySet How are strings sorted alphabetically and dates chronologically using the same f unction (Collections.sort)? They both implement the Comparable interface (it has the compareTo method). How do you sort a collection in an order other than their natural order? With a Comparator object (implements the comparator interface). What are the operations of SortedSet? subSet, tailSet, headSet, first, last, comparator. What are the operations of SortedMap? subMap, headMap, tailMap, firstKey, lastKey, comparator. What kinds of implementations are there in the Java Collections Framework? general purpose, special purpose, concurrent, convenience, wrapper, abstract What are the implementations of the Set interface? HashedSet, TreeSet, LinkedHashSet What special implementation of the Set interface are there? EnumSet, CopyOnWriteArraySet What are the List interface implementations? ArrayList, LinkedList What are the List interface specifications? CopyOnWriteArrayList What are the Map implementations? HashMap, TreeMap and LinkedHashMap. What are the interfaces of the Queue interface? LinkedList and Priority Queue What are the synchronization wrappers? They are static functions of the Collection types which return synchronized vers ions. What are unmodifiable wrappers? They ensure that the collection cannot be modified.

What are some convenience implementations of the Java Collections Framework inte rfaces? Array.asList, Collections.singleton, Collections.emptySet (map,list), Collection s.nCopies How do you sort a collection? Collections.sort(someCollection); Collections.sort(someCollection, someComparatorObject); What collections can be shuffled? How do you shuffle a collection? Lists can be shuffled. Collections.shuffle(someList); Collections.shuffle(someList, someRandomObject); What algorithm is used for searching? Collections.binarySearch(list, key) (also variant with Comparator argument speci fied). How do you find out how often an element is within a collection? Collections.frequency How do you find out if two collections have no element in common? Collections.disjoint How do you find the minimum and maximum values in a collection? Collections.min and Collections.max What routine data manipulation algorithms are in the Java Collections Framework (5 methods)? reverse, fill, copy, swap, addAll What are some basic controls in Swing? (10 Java classes) JButton, JCheckBox, JComboBox, JList, JTextField, JMenu, JSlider, JSpinner, JRad ioButton, JPasswordField. What controls do you use for highly formatted information? (8 Classes) JTextPane, JColorChooser, JFileChooser, JTable, JTextArea, JEditorPane, JTextPan e, JTree, JTable. What are some uneditable information displays? (4 Classes) JProgressBar, JLabel, JSeparator, JToolTip What are the 3 top level containers in Java? JApplet, JDialog, JFrame(this one is a window actually.. just like in Emacs). What are the general purpose containers in Java? (5) JPanel, JScrollPane, JSplitPane, JToolbar, JTabbedPane How do you do MDI in Java? JInternalFrame What is a layered pane? A JLayeredPane is a panel which provides depth for the objects. What is a root pane? The main pane in a mdi application, or applet, etc. JRootPane How do you run an applet from a JAr file? <applet code=ClassName.class archive="JarFileName.jar" width=width height=height ,

</applet> How do you run a jar archive? java -jar JarFileName.jar What are the formats for extracting, viewing, creating and updating jar files? jar -xf (or tf, cf, uf) filename How do you get verbose input from jar? With the v parameter. How do you specify no compression on the jar file? With the 0 parameter How do you specify the main class in a jar file? Create a manifest with the Main-Class specified and use the m parameter. OR Use the e parameter How do you change directories in a Jar file? The C parameter What is the pathname of the manifest? META-INF/MANIFEST.MF What is the content of the default manifest? Manifest-Version: 1.0 Created-By: 1.6.0 (Sun Microsystems Inc.) How do you modify the main class of a manifest? Main-Class: classname How do you add classes to a JAR file? With the Class-Path: line in a manifest file then use the -m switch. What does it mean to seal a package? It means that all the classes of the package can only be accessed within that Ja r file. How do you seal a package? Name: .. Sealed: True What are some version informations that can be added to a Jar file? Name: java/util/ // Name of the package Specification-Title: Java Utility Classes Specification-Version: 1.2 Specification-Vendor: Sun Microsystems, Inc. Implementation-Title: java.util Implementation-Version: build57 Implementation-Vendor: Sun Microsystems, Inc.

Vous aimerez peut-être aussi