What is scanner class in java?
The Scanner class alows users to enter data. Example:
import java.util.Scanner
Scanner scan = new Scanner (System.in);
String input;
System.out.println ("Enter a word or phrase.")
input = scan.nextLine ();
System.out.println ("You entered: " + input);
Why java is an extensible programming language?
How can loops be used to process arrays?
Loops can be used to iterate or walk through an array. For example, suppose you have an array already initialized (we'll call it "array"):
int target = -1;
for (i=0; i < array.length(); i++){
if (array[i] = target){
//do something
}
}
Here, we will walk through an array (note that arrays are zero indexed) using a loop to make sure we hit each element of the array. In our loop, we start at the head (or first element) and iterate over each element.
Error: Any departure from the expected behavior of the system or program, which stops the working of the system is an error.
Exception:Any error or problem which one can handle and continue to work normally.
Note that in Java a compile time error is normally called an "error," while a runtime error is called an "exception."
Errors don't have subclasses while exception has two subclasses, they are compile time exception or checked exception (ClassNotFound Exception, IOException, SQLException etc.) and runtime or unchecked exception(ArrayIndexOutOfBounds Exception, NumberFormat Exception).
Is it necessary to implement all the methods of abstract classes in derived class?
An Abstract class is a way to organize inheritance, sometimes it makes no since to implement every method in a class (i.e. a predator class), it may implement some to pass to its children but some methods cannot be implemented without knowing what the class will do (i.e. eat() in a Tiger class). Therefore, abstract classes are templates for future specific classes.
A disadvantage is that abstract classes cannot be instantiated, but most of the time it is logical not to create a object of an abstract class. heloooooo
What is the primary benefit of byte code?
The whole idea of Java - or one of the ideas, at any rate - is that it can be run anywhere. So, instead of compiling for a specific processor, the Java compiler compiles for a "generic processor", called the Java Virtual Machine. The code thus generated is called "bytecode". It can be interpreted (i.e., run) by a Java Virtual machine, these are available on different platforms.
The whole idea of Java - or one of the ideas, at any rate - is that it can be run anywhere. So, instead of compiling for a specific processor, the Java compiler compiles for a "generic processor", called the Java Virtual Machine. The code thus generated is called "bytecode". It can be interpreted (i.e., run) by a Java Virtual machine, these are available on different platforms.
The whole idea of Java - or one of the ideas, at any rate - is that it can be run anywhere. So, instead of compiling for a specific processor, the Java compiler compiles for a "generic processor", called the Java Virtual Machine. The code thus generated is called "bytecode". It can be interpreted (i.e., run) by a Java Virtual machine, these are available on different platforms.
The whole idea of Java - or one of the ideas, at any rate - is that it can be run anywhere. So, instead of compiling for a specific processor, the Java compiler compiles for a "generic processor", called the Java Virtual Machine. The code thus generated is called "bytecode". It can be interpreted (i.e., run) by a Java Virtual machine, these are available on different platforms.
What do you mean by derived data type in java?
A data type of an object describes the kind of information stored in that object. Numbers, strings, images, and all other information in a program is described by some sort of data type.
a Java application is a program written with the very popular porgramming language (Java). the Java programs can run on any operating system (windows,linux,mac...etc) and also it can be run on mobile devices too. in order to the java application to run,it needs to have JRE(Java Runtime Enviroment)installed on the device that it will run on.
How nesting of methods is done in java?
No, Java only allows a method to be defined within a class, not within another method.
Is it possible to declare a variable in a method and use it in a main?
Yes you can and they are known as inner methods. You can even delcare an inner class and methods on it. However, if you want your classess accessible from multiple programs (reusability), then you should not use this practice. This type of facility is useful when you know for sure that your class or method is going to be used only once.
It is a happening, the result of an action or an item in a programme
Write a simple java program using exceptions?
Here's a Hello World application:
import static java.lang.System.out;
class HelloWorld
{
public static void main(string[] arguments)
{
out.println("Hello world!") //this will print out the words 'Hello world!' to the screen
} //End of main method
} //End of class HelloWorld
Why you required zero length array in java?
Yes. We can create an array of zero length in JAVA. Here is an example:
class ForFun
{
int[] nullArray=new int[0];
public someMethod()
{
for(int j=0; j System.out.print(nullArray[j]); } } In the above program, an array named nullArray is created and is allocated memory. But its size is zero and we cannot insert any value into it. It just occupies the memory. Hope this answers your question. :)
This section demonstrates you the use of DataInputStream class.
The class DataInputStream allows to read primitive Java data types from an underlying input stream. It reads the file line by line.
How do you prevent method overriding in java?
Use the word "final" directly preceding your method declaration. The presence of final keyword directs java to ensure that, this particular method would not be overridden by any of its child classes.
Java itself is freely distributed. You may have to pay for programs written in Java, however.
Why operator overloading is not there in java?
== == === === === === === === Some Body told me that operator overloading is not there because it violates the transparency of java.since there is no hiding of information in java it does support op overloading
=== === === === === === Pranab Kumar Rana
Software Engineer.....
=== === === ===
What is good programming style?
There are 2 major goals easily to say than done in any programming:
Any technique that can lead you to those 2 goals are superbly good.
How can two methods have the same signature?
Two methods can have the same signature when you override a method. A superclass calledrectangle might have a method called draw(). Then you make a subclass called squareand give it a method called draw() also. When you call the draw() method from square, it overrides the draw() method in rectangle. Note this is different than overloading, where you have two methods with the same name but different signatures, like draw() and draw(Color c).
Write a java program to create human face?
Try this for a very, very simple face....
String hair = " /////// ";
String eyes = " | o o | ";
String noseEars = "(| ^ |)";
String mouth = " | [ ] | ";
String chin = " ------ ";
System.out.println(hair); //prints out the hair
System.out.println(eyes); //prints out the eyes
System.out.println(noseEars); //prints out the nose and ears
System.out.println(mouth); //prints out the mouth
System.out.println(chin); //prints out the chin
nAbility to tackle challenging problems
nImproved communication between users, analysts, designers, and programmers
nIncreased consistency in analysis, design, and programming
nExplicit representation of commonality among system components
nSystem robustness
nReusability of analysis, design, and programming results
What are the advantages of Java programs?
Here we list some of the major benefits that Java can provide for general science and engineering applications:
What is the difference between entry and exit controlled loops - in Java?
while loop and for loop are entry controlled loops as they check looping condition at the entry point.
do while loop is exit controlled loop as it checks looping condition at exit point.
shreeradha@yahoo.com
What is the general syntax of a default constructor?
There is no such thing as 'the general syntax of a default constructor'. A default constructor is one that is generated by the compiler if you don't specify any constructors at all. Semantically speaking, it is public and takes no arguments, but this is not 'syntax'.