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

Why is Java called an Object Oriented Programming Language?

Actually java is not purely object oriented.because we can use the primitive data types in Java.In java all those things or considered as classes and objects .So we are called java is an object oriented programming language...

How can you connet java with sql in java programming?

JDBC mean Java Database Connectivity. In java, using JDBC drivers, we can connect to database.

Steps to connect to JDBC.

1) Load the driver, using Class.forName(DriverName);

2) Get the connection object, Connection con = Driver.getConnection(loaded driver name);

3) Create a SQL statement, Statement s = con.createStatement();

4) Create Resultset object using the statement created above, ResultSet rs = s.executeQuery("sql statement");

Iterate the result set to get all the values from the database.

Finally don't miss this

5) s.close();

6) con.close() ;

Encapsulation method used in java with example programme?

The ability to make changes in your code without breaking the code of all others who use your code is a key benefit of encapsulation. You should always hide implementation details. To elaborate, you must always have your variables as private and then have a set of public methods that others can use to access your variables. Since the methods are public anyone can access them, but since they are in your class you can ensure that the code works the way that is best for you. So in a situation that you want to alter your code, all you have to do is modify your methods. No one gets hurt because i am just using your method names in my code and the code inside your method doesnt bother me much.

What do you mean by instance of the class?

I have no idea. Was going to ask you the same question...An instance method represent the behavior of an object

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