answersLogoWhite

0

📱

Java Programming

The Java programming language was released in 1995 as a core component of the Java platform of Sun Microsystems. It is a general-purpose, class-based, object-oriented language that is widely used in application software and web applications.

5,203 Questions

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?

  1. By connecting to the Internet, a user immediately has access to thousands of programs and other computers .
  1. During the execution of a program, Java can dynamically load class libraries that it requires either from the local hard drive, from another computer on the local area network or from a computer somewhere on the Internet.

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.

Is error and exception same?

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.

How to make java application?

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.

What is event and method?

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. :)

What is DataInputStream?

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.

Does java charge you monthly?

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:

  1. The software works as desired
  2. The software is maintainable

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

Object oriented advantages?

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:

  • Platform Independence
    Scientists use more types of computers and OS's that most other groups. Code that can be exchanged without requiring rewrites and recompilation saves time and effort.

  • Object Oriented
    Besides the usual benefits from OOP, many scientific programs can benefit from thinking in terms of objects. For example, particles in a scattering simulation are naturally self-contained objects.

  • Threading
    Multi-processing is very useful for many scientific tasks, such as, for example, simulations of phenomena where many processes occur simultaneously.

  • Networking
    Java comes with many networking capabilities that allow one to build distributed systems. Such capabilities can be applied, for example, to remote data taking from sensors.

  • Embedded Applications
    The original Oak language from which Java derived was intended for embedded applications. Platform independence and the other items mentioned above, as well as the adaptability of Java that allows it to work on micro-sized platforms by shedding nonessential code, has made Java very popular for use in embedded devices such as smart cards and cell phones. It can thus also be embedded into sensors, controllers, and other types of engineering and scientific devices. See Chapter 23 for more discussion about this.

  • Distributed Computing
    In chapters 16-20 we will examine how Java can effectively distribute computational power over many systems and use this capability to tackle tough scientific and engineering analysis problems.

  • Interfacing & Enhancing Legacy Code
    Java's strong graphics and networking capabilities can be applied to existing C & Fortran programs. There have been mountains of very important and complex programs, especially for numerically intensive tasks, created over the decades in these languages and it would be too expensive to reprogram them in a different language.

    Java, however, can connect to such programs and bring to them new capabilities. For example, a Java graphical interface can bring enhanced ease of use to a Fortran or C program, which then acts as a computational engine behind the GUI.

    Similarly, Java's networking features can bring far greater accessiblity to these programs.

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