Archive for java aptitude questions
You are browsing the archives of java aptitude questions.
You are browsing the archives of java aptitude questions.
41. Listing the Main Attributes in a JAR File Manifest
Jar Manifest file is the main section of a jar file. This file contains the detailed information about the specific individual jar file. It contains the complete information about the jar file, each and every section or particular information is separated by new line.
42. Creating a ZIP File
Zip [...]
21. Creating a Copy of a Collection
This tells how to create and then copy the collection. The copied collection contains the reference to the object. In-fact, objects are not cloned.
22. Making a Collection Read-Only
This section describes you how to make a collection read-only. In this section, list (component of the collection) has been represented for making it [...]
The util package or java provides many utility interfaces and classes for easy manipulation of in-memory data. The java util package tutorials at RoseIndia.net introduces you with the Java util package of JDK. All the examples are with free source code. It includes many examples that demonstrate the syntax and example code of java [...]
Java Features
Platform Independent
The concept of Write-once-run-anywhere (known as the Platform independent) is one of the important key feature of java language that makes java as the most powerful language. Not even a single language is idle to this feature but java is more closer to this feature. The programs written on one platform can run [...]
There are four main pillars of an Object Oriented Programming Language :
• Inheritance:
Inheritance provide the facility to drive one class by another using simple syntax. You can say that it is a process of creating new class and use the behavior of the existing class by extending them for reuse the existing code and adding the [...]
Java Virtual Machine (JVM)
It is the principal component of Java architecture that provides the cross platform functionality and security to Java. This is a software process that converts the compiled Java byte code to machine code. Byte code is an intermediary language between Java source and the host system.
Most programming language like C [...]
What is Java?
Java is a high-level object-oriented programming language developed by the Sun Microsystems. Though it is associated with the World Wide Web but it is older than the origin of Web. It was only developed keeping in mind the consumer electronics and communication equipments. It came into existence as a part of web application, [...]
Q: What if the main method is declared as private?
A: The program compiles properly but at runtime it will give “Main method not public.” message.
Q: What if the static modifier is removed from the signature of the main method?
A: Program compiles. But at runtime throws an error “NoSuchMethodError”.
Q: What if I write static public void instead of public static [...]
What is the difference between URL instance and URLConnection instance?
ANSWER : A URL instance represents the location of a resource, and a URLConnection instance represents a link for accessing or communicating with the resource at the location.
2) How do I make a connection to URL?
ANSWER : You obtain a URL instance and then invoke openConnection [...]
1) The API doesn’t list any constructors for InetAddress- How do I create an InetAddress instance?
ANSWER : In case of InetAddress the three methods getLocalHost, getByName, getByAllName can be used to create instances.
E.g.
InetAddress add1;
InetAddress add2;
try{
add1 = InetAddress.getByName(“java.sun.com”);
add2 = InetAddress.getByName(“199.22.22.22″);
}catch(UnknownHostException e){}
2) Is it possible to get the Local host IP?
ANSWER : Yes. Use InetAddress’s getLocalHost method.
3) [...]