Archive for java freshers questions

You are browsing the archives of java freshers questions.

Java Util Examples List part-III (data structures in java)

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 [...]

Java Util Examples List part-II (data structures in java)

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 [...]

Java Util Examples List part-I (data structures in java)

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 [...]

Advantages of Java in brief

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 [...]

What is JVM in java……….a brief description

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 …… A brief description!!!!

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, [...]

Java-Fundamental concepts through OOPS

Q) OOPS concepts
Polymorphism
Ability to take more than one form, In java we achieve this using Method Overloading (compile time polymorphism), Method overriding (runtime polymorphism)
Inheritance
Is the process by which one object acquires the properties of another object.
Encapsulation
Wrapping of data and function into a single unit called encapsulation. Ex:- all java programs.
Abstraction
Nothing but representing the essential futures [...]

Java questions with one word answers

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 [...]

Java- Technical questions on Servlets

1) What is the servlet?
ANSWER : Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company’s order database.
Servlets are to servers what applets are to browsers. Unlike applets, [...]

Java- Technical questions on Networking

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 [...]

Java- Technical question on Networking Concepts

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) [...]

Java-Technical questions on Utility Package

1) What is the Vector class?
ANSWER : The Vector class provides the capability to implement a growable array of objects.
2) What is the Set interface?
ANSWER : The Set interface provides methods for accessing the elements of a finite mathematical set.Sets do not allow duplicate elements.
3) What is Dictionary class?
ANSWER : The Dictionary class is the [...]

Java- error finding questions Part-I

What is the result of executing the following Java class:

import java.awt.*;
public class FrameTest extends Frame {
public FrameTest() {
add (new Button("First"));
add (new Button("Second"));
add (new Button("Third"));
pack();
setVisible(true);
}
public static void main(String args []) {
new FrameTest();
}
}

1) Nothing happens.
2) Three buttons are displayed across a window.
3) A runtime exception is generated (no layout manager specified).
4) Only the “first” button is [...]

Java-Programitical questions, logical questions,technical questions part-II

This paper gives an idea about Java programmatic questions and logicals that are being asked in interviews for freshers and experienced people.
And also don’t forget to read another part of this series here,
also check out complete Java section if you want to be master in Java

Examine the following class definition:

public class [...]

Java-Programitical questions, logical questions,technical questions part-I

This paper gives an idea about java coding questions for freshers which are helpful for interview exams…

What class must an inner class extend:
1) The top level class
2) The Object class
3) Any class or interface
4) It must extend an interface
Answer 3
In the following code, which is the earliest statement, where the object originally held in e, [...]

Java- Programmitical questions, logical questions

Which colour is used to indicate instance methods in the standard “javadoc” format documentation:
1) blue
2) red
3) purple
4) orange
Answer : 2

explain
In JDK 1.1 the variabels, methods and constructors are colour coded to simplifytheir identification.
endExplain
What is the correct ordering for the import, class and package declarations when found in a single file?
1) package, import, class
2) [...]

Java- Technicl questions on AWT: CONTROLS, LAYOUT MANAGERS AND MENUS

What is meant by Controls and what are different types of controls?
Ans : Controls are componenets that allow a user to interact with your application.The AWT supports the following types of controls:
Labels
Push buttons
Check boxes
Choice lists
Lists
Scroll bars
Text components
These controls are subclasses of Component.
You want to construct a text area that is 80 character-widths wide and 10 [...]

Java-Technical questions on APPLETS

What is an Applet? Should applets have constructors?
Ans : Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java capable browser. We don’t have the concept of Constructors in Applets.
How do we read number information from my applet’s parameters, given that Applet’s getParameter() method returns a [...]

Java-Technical questions on EVENT HANDLING

The event delegation model, introduced in release 1.1 of the JDK, is fully compatible with the event model.
True
False
Ans : b.

A component subclass that has executed enableEvents( ) to enable processing of a certain kind of event cannot also use an adapter as a listener for the same kind of event.
True
False
Ans : b.
What is the highest-level [...]

Java-Technical question on INPUT / OUTPUT : EXPLORING JAVA.IO

What is meant by Stream and what are the types of Streams and classes of the Streams?
Ans : A Stream is an abstraction that either produces or consumes information.
There are two types of Streams. They are:
Byte Streams : Byte Streams provide a convenient means for handling input and output of bytes.
Character Streams : Character [...]

Java-Technical questions on EXPLORING JAVA.LANG

java.lang package is automatically imported into all programs.
True
False
Ans : a
What are the interfaces defined by java.lang?
Ans : Cloneable, Comparable and Runnable.
What are the constants defined by both Flaot and Double classes?
Ans : MAX_VALUE,
MIN_VALUE,
NaN,
POSITIVE_INFINITY,
NEGATIVE_INFINITY and
TYPE.
What are the constants defined by Byte, Short, Integer and Long?
Ans : MAX_VALUE,MIN_VALUE and TYPE.
What are the constants defined by [...]

Java- Technical questions on STRING HANDLING

Which package does define String and StringBuffer classes?
Ans : java.lang package.
Which method can be used to obtain the length of the String?
Ans : length( ) method.
How do you concatenate Strings?
Ans : By using ” + ” operator.
Which method can be used to compare two strings for equality?
Ans : equals( ) method.
Which [...]

Java- Technical questions on Inheritance

1) What is the difference between superclass & subclass?
Ans : A super class is a class that is inherited whereas subclass is a class that does the inheriting.
2) Which keyword is used to inherit a class?
Ans : extends
3) Subclasses methods can access superclass members/ attributes at all times?
True/False
Ans : False
4) When can subclasses not [...]

Java-Technical questions on Exception handling

1) What is the difference between ‘throw’ and ‘throws’ ?And it’s application?
Ans : Exceptions that are thrown by java runtime systems can be handled by Try and catch blocks. With throw exception we can handle the exceptions thrown by the program itself. If a method is capable of causing an exception that it does not [...]

Java-Technical questions on packages and interfaces

1) What are packages ? what is use of packages ?
Ans :The package statement defines a name space in which classes are stored.If you omit the package, the classes are put into the default package.
Signature… package pkg;
Use: * It specifies to which package the classes defined in a file belongs to. * Package is both [...]

Java-Technical questions on control strutures,methods,classes

1) What are the programming constructs?
Ans: a) Sequential
b) Selection — if and switch statements
c) Iteration — for loop, while loop and do-while loop
2) class conditional {
public static void main(String args[]) {
int i = 20;
int j = 55;
int z = 0;
z = i < j ? i : j; // ternary operator
System.out.println(”The value assigned is ” [...]

Java- Technical questions on Operators

1) What are operators and what are the various types of operators available in Java?
Ans: Operators are special symbols used in expressions.
The following are the types of operators:
Arithmetic operators,Assignment operators, Increment & Decrement operators, Logical operators, Biwise operators, Comparison/Relational operators and Conditional operators.
2) The ++ operator is used for incrementing and the — operator is [...]

Java- questions on Data types,variables and Arrays

1) What is meant by variable?
Ans: Variables are locations in memory that can hold values. Before assigning any value to a variable, it must be declared.
2) What are the kinds of variables in Java? What are their uses?
Ans: Java has three kinds of variables namely, the instance variable, the local variable and the class variable.
Local [...]

Complete Java questions collection

Complete Java programmer interview questions
1. What is the purpose of finalization?
- The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
2.What is the difference between the Boolean & operator and the && operator?
- If an expression involving the Boolean & [...]

java- j2ee interview questions part-v

251. What is renderer
A Java class that can render the output for a set of JavaServer Faces UI components.
252. What is request-response messaging
A method of messaging that includes blocking until a response is received.
253. What is resource adapter
A system-level software driver that is used by an EJB container or an [...]