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 portions of a super class can be used by subclass?

Any members of a superclass which are declared as public or protected can be used by all subclasses.

What is CSharp?

The C# sharp programming language is a relatively young programming language created by Microsoft. It is heavily influenced by another (and older) programming language called C++, which in itself is often regarded as a succesor to the programming language C. As far to my knowledge C# is only used in order to develop .NET based applications.

Type of inheritance?

There are 2 Types of genetic Inheritance.

1. Polygenic inheritance, also known as quantitative or multi-factorial inheritance refers to inheritance of a phenotypic characteristic (trait) that is attributable to two or more genes and their interaction with the environment.

Polygenic traits do not follow patterns of Mendelian inheritance (qualitative traits). Instead, their phenotypes typically vary along a continuous gradient depicted by a bell curve. Eye color and skin color are both polygenetic traits.

2. Monogenic inheritance is controlled by a single gene, as opposed to multigenic.

Why was Whitney method of manufacturing muskets superior to the earlier method?

the new inventions he invented of working metals and forming the several parts of a musket, are practically useful and highly important to his country. Whitney’s methods brought him the wealth he had sought. They also inspired other inventors to produce affordable consumer goods such as clocks and sewing machines.

What is the difference between component and container?

A component is an object, like a button or a scroll bar. It has a visual representation. A container is a window-like component that can contain other components. Every component has a unique container that directly contains it.

What is array data?

Basically it's a list.

Instead of typing x0, x1, x2, x3, x4... x99, an array lets you just type x[100]. Then to use each variable you just type x[number] and use it as normal. Arrays are so useful because you can iterate, or repeat, over them easily. You could define an array, then define an integer i. They you could make a loop in your program that increases each x value by 2. Just make it so I gets bigger each run of the loop and type this:

x[i] = x[i] + 2

A Note: if you define the array x to have 100 values, than it will go from 0 to 99, not 1 to 100.

There are also more advanced arrays that can get bigger as you need them to. They will grow without you thinking about it. You can also add data in the middle, and have all the data after it shifted one place. Or you could delete a piece of data from the middle and have all data after it shifted back one place. These arrays are generally called mutable (which means changeable) arrays. Normal arrays are called immutable arrays.

Why Inheritance is required in java?

OOP, is to write software in objected-oriented fashion. It will be very difficult to do this with a non-objected oriented computer language. Any objected oriented computer language must have INHERITANCE feature to be an OO language. Actually, to be called object-oriented of anything, inheritance is a must. Without inheritance, it will not be OO (of anything).

Like any feature, characteristic, or property of "something" (oop in this question), the "importance" may only be concluded or derived from understanding it and perhaps even applying it. Inheritance is built into OOP, try to apply it, then you will understand its importance and perhaps discover its weakness!

What is the best programming language to make an MMORPG with?

There are many options; the best language is probably the one you know best. Some languages may be better than others, but no language is inherently superior to all others, whether you want to make an MMORPG, or any other task.

What is java jre and java jdk?

== == JRE includes (JVM ) java virtual machine and some other library files. That runs a java application. JVM - understand the corresponding byte code of a java class and make it ready for run. The Java Runtime Environment (JRE) is an implementation of the JVM (Java Virtual Machine) that actually executes our java programs.

The Java Virtual Machine (JVM) is created, like a separate program, whenever a java program is executed. The JVM essentially runs between the computer and the java program. Java is designed so that any java program can run on any machine. This is because the JVM will interpret the Operating System independent java code and execute the commands needed for the particular Operating System you are trying to run the program on at the time.

Java Program --- Execute some command ---> JVM --- Translate the command for this computer ---> Computer

Java Virtual Machine (JVM) A Java Virtual Machine (JVM) is a set of computer software programs and data structures that use a virtual machine model for the execution of other computer programs and scripts. The model used by a JVM accepts a form of computer intermediate language commonly referred to as Java bytecode. This language conceptually represents the instruction set of a stack-oriented, capability architecture. As of 2006, there are an estimated four billion JVM-enabled devices worldwide. Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system

What are two main purposes of the Java compiler javac?

One of them is creating *.class from *.java

Second is identifying syntax errors in the *.java files and intimating the programmer so that he can correct them

What is derived class in brief?

A derived class is any class that inherits from one or more other classes, known as base classes. The derived class inherits the sum total of all public and protected members of all its base classes, including their base classes. The derived class is a more specialised form of its base classes. Any members of the base classes that are declared virtual can be overridden, such that calling the base class method directly actually invokes the derived class method, thus enabling polymorphic behaviour.

How do you draw a polygon?

draw a square , mark a point at the center then mark the points at the sides of the square according to the amount of sides.then join the points , at last erase the unwanted lines inside the formed shape,and you are done.

What is unchecked exception?

A checked exception is an exception which the Java source code must deal with, either by catching it or declaring it to be thrown. Unchecked exceptions are all exceptions which do not follow this rule.

When an unchecked exception is thrown, it is usually caused by a misuse of code - passing a null or otherwise incorrect argument. This includes classes like NullPointerException and IllegalArgumentException.

Checked exceptions are generally caused by faults outside of the code itself - missing resources, networking errors, and problems with threads come to mind. These could include subclasses of FileNotFoundException, UnknownHostException, etc.

The Java documentation (link below) gives some loose guidelines to follow when trying to decide which type of exception to use: "If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception."

From a purely code-oriented point of view, a checked exception is a subclass of Exception, while an unchecked exception is a subclass of RuntimeException.

What are strings in java?

The String class is defined in the java.lang package and hence is implicitly available to all the programs in Java. The String class is declared as final, which means that it cannot be subclassed. It extends the Object class and implements the Serializable, Comparable, and CharSequence interfaces.

Why constructor does not have return type?

Constructors cannot have return types. The main job of the constructor is to create new instance of its class and return that instance. So the default return type of all constructor is the object of its class.

Why java does not support destructor?

AMIT KUMAR

  • 3th Nov , 2014
Java does not support destructors, since java supports the concept of garbage collection,hence the garbage collector is used to automatically free the space which has occupied by the program while running.Garbage collector calls the finalize() method which is defined in the object class. finalize() method is called once for each object.

2 Write a program in java to find factorial of a number?

import java.math.BigInteger;

public class Factorial {

public static void main(String[] args) {

BigInteger n = BigInteger.ONE;

for (int i=1; i<=20; i++) {

n = n.multiply(BigInteger.valueOf(i));

System.out.println(i + "! = " + n);

}

What are the main differences between user-defined exceptions and system-defined exception?

Systems don't throw exceptions. System errors are low-level errors which you have to detect programmatically. In C, most functions that cause system errors will typically return -1 to indicate an error has occurred and 0 to indicate no error. If an error occurs, you should examine the global errno variable to determine the actual error code (as defined in <errno.h>). You can use the strerror() function to obtain a pointer to the string representation of the error, and perror() to display the error.

If you cannot handle the error there and then, then you should pass the error to your error handling code. Languages that support exception handling make it easy to pass errors from the point they are detected to a point where they can be handled. Simply transform the error code into an exception object and then throw the object, allowing the exception handling mechanism to deal with it.

In which year java was invented?

In 1977, James Gosling received a B.Sc in Computer Science from the University of Calgary. In 1983, he earned a Ph.D in Computer Science from Carnegie Mellon University, and his doctoral thesis was titled "The Algebraic Manipulation of Constraints". While working towards his doctorate, he wrote a version of emacs (gosmacs), and before joining Sun Microsystems he built a multi-processor version of Unix[1] while at Carnegie Mellon University, as well as several compilers and mail systems.

Since 1984, Gosling has been with Sun Microsystems, and is generally known best as the father of the Java programming language.

[edit] ContributionsHe is generally credited as the inventor of the Java programming language in 1991. He created the original design of Java and implemented its original compiler and virtual machine. For this achievement he was elected to the United States National Academy of Engineering. He has also made major contributions to several other software systems, such as NeWS and Gosling Emacs. He also cowrote the "bundle" program, a utility thoroughly detailed in Brian Kernighan and Rob Pike's book The Unix Programming Environment. [edit] HonorsIn 2007, he was made an Officer of the Order of Canada.[2] The Order is
1995

Do you use virtual functions in Java?

Every method in java that isn't a class (static) method is automatically "virtual." If you want to disable virtual overrides, make the method "final" in the base class.

What is difference between pass by value and pass by reference in VB?

Let's say we have an integer variable named x.

A call to a function by value using x means (a copy of) the value that x stores is passed in the function call and no matter what the function does with that value, the value stored in x remains unchanged.

A call to a function by reference using x means a reference (also called a pointer or alias) to the variable x is passed in the function call and so any changes the function makes using this reference will actually change the value stored in x.

call by value:

--- In this technique, the changes made in the function definition are not reflected in main program.

--- The original value is intact an a copy of it is being modified.

--- example:

int swap(int , int);

int main()

{

int a=10, b=20;

swap(a,b);

}

int swap(int c ,int d);

{

int temp;

temp=c;

c=d;

d=temp;

}

--- here, if the printf statement is given in the function definition then it would print "a=20, b=10" and if given in the main program it would print "a=10, b=20"

--- therefore, the original value is intact and the copy of it has being modified....

call by reference:

--- In this technique, the changes made in the function definition are reflected in main program.

--- The original value is not intact an original data is being modified.

--- example:

int swap(int* , int*);

int main()

{

int a=10, b=20;

swap(&a,&b);

}

int swap(int *c ,int *d);

{

int *temp;

*temp=*c;

*c=*d;

*d=*temp;

}

--- here, if the printf statement is given in the function definition then it would print "a=20, b=10" and if given in the main program it would print the same "a=20, b=10"

--- therefore, the original value is not intact and its being modified....

  • There are two ways of passing arguments/parameters to a function. One method is Call by Value and the other method is Call by Reference.

    Call by Value: in the Call by Value the programming is sending the copy of an argument/parameter to a function. Programmer is not passing the actual variable. Since only the copy of the variable is passed to the function therefore any changes/modifications made within a function don't affect the variable and the variable value remains the same after the function call.

  • The arguments passed to function can be of two types namely

    1. Values passed

    2. Address passed

    The first type refers to call by value and the second type refers to call by reference.

    For instance consider program1

    main()

    {

    int x=50, y=70;

    interchange(x,y);

    printf("x=%d y=%d",x,y);

    }

    interchange(x1,y1)

    int x1,y1;

    {

    int z1;

    z1=x1;

    x1=y1;

    y1=z1;

    printf("x1=%d y1=%d",x1,y1);

    }

    Here the value to function interchange is passed by value.

    Consider program2

    main()

    {

    int x=50, y=70;

    interchange(&x,&y);

    printf("x=%d y=%d",x,y);

    }

    interchange(x1,y1)

    int *x1,*y1;

    {

    int z1;

    z1=*x1;

    *x1=*y1;

    *y1=z1;

    printf("*x=%d *y=%d",x1,y1);

    }

    Here the function is called by reference. In other words address is passed by using symbol & and the value is accessed by using symbol *.

    The main difference between them can be seen by analyzing the output of program1 and program2.

    The output of program1 that is call by value is

    x1=70 y1=50

    x=50 y=70

    But the output of program2 that is call by reference is

    *x=70 *y=50

    x=70 y=50

    This is because in case of call by value the value is passed to function named as interchange and there the value got interchanged and got printed as

    x1=70 y1=50

    and again since no values are returned back and therefore original values of x and y as in main function namely

    x=50 y=70 got printed.

How does one initialize a byte array in Java?

One can get information about how to initialize a byte array in java on the website stackoverflow dot com. That website can learn one a lot about java.

Difference between portability and platform independent?

Platform independence refers to the fact that java compiled code (byte code) can execute on any operating system. A programme is written in a language that can be understood by humans. It could contain words, phrases, or other information that the system doesn't understand.... The Java Byte Code is the intermediate representation in Java.

To learn more about data science please visit- Learnbay.co