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

Sort the following list using selection sort and insertion sort show the list after each it eration and this is the list 10 6 1 23 56 22 3 17?

The difference between selection sort and insertion sort is simple: selection sort is an in place sort, while insertion sort builds the sorted array one element at a time.

Selection sort:

[10, 6, 1, 23, 56, 22, 3, 17]

[1, 10, 6, 23, 56, 22, 3, 17]//1 is placed in its final correct position

[1, 3, 10, 23, 56, 22, 6, 17]//3 is placed in its final correct position

[1, 3, 6, 23, 56, 22, 10, 17]//6 is placed in its final correct position

[1, 3, 6, 10, 56, 23, 22, 17]//10 is placed in its final correct position

[1, 3, 6, 10, 17, 56, 23, 22]//17 is placed in its final correct position

[1, 3, 6, 10, 17, 22, 56, 23]//22 is placed in its final correct position

[1, 3, 6, 10, 17, 22, 23, 56]//23 is placed in its final correct position

Insertion sort:

[10, 6, 1, 23, 56, 22, 3, 17]

[6, 10, 1, 23, 56, 22, 3, 17]//The first two elements of the list are correctly sorted

[1, 6, 10, 23, 56, 22, 3, 17]//The first three elements of the list are correctly sorted

[1, 6, 10, 23, 56, 22, 3, 17]//The first four elements of the list are correctly sorted

[1, 6, 10, 23, 56, 22, 3, 17]//The first five elements of the list are correctly sorted

[1, 6, 10, 22, 23, 56, 3, 17]//The first six elements of the list are correctly sorted

[1, 3, 6, 10, 22, 23, 56, 17]//The first seven elements of the list are correctly sorted

[1, 3, 6, 10, 17, 22, 23, 56]//The eight elements of the list are correctly sorted

Explain what a random number is?

That means that a number is selected randomly from a certain set. For example, if you throw a die, you can randomly get any of the integers from 1 to 6. It is random, because you don't know the result in advance.

That means that a number is selected randomly from a certain set. For example, if you throw a die, you can randomly get any of the integers from 1 to 6. It is random, because you don't know the result in advance.

That means that a number is selected randomly from a certain set. For example, if you throw a die, you can randomly get any of the integers from 1 to 6. It is random, because you don't know the result in advance.

That means that a number is selected randomly from a certain set. For example, if you throw a die, you can randomly get any of the integers from 1 to 6. It is random, because you don't know the result in advance.

Write a java program to print first 50 palindrome numbers?

Just change the number assigned to P if you want a different number of palindromes:

public class PalindromeNumbers {

public static final int P = 50;

public static void main(String[] args) {

getNums(P);

}

public static void getNums(int n) {

int count = 0, current = 1;

while(count < n) {

if(palindrome("" + current) {

System.out.println(current);

count++;

}

current++;

}

public static boolean palindrome(String s) {

if(s.length() s.charAt(s.length - 1) return palindrome(s.substring(1, s.length - 2)

else return false;

}

}

How do you run a java program form the command prompt?

The command is "java", followed by the class name. For example, if your compiled class is called myclass.class, you give the command:

java myclass

Explain why naming encapsulation are important for developing large?

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.

If you want maintainability, flexibility, and extensibility (and I guess, you do), your design must include encapsulation. How do you do that?

• Keep instance variables protected (with an access modifier, mostly private).

• Make public accessor methods, and force calling code to use those methods rather than directly accessing the instance variable.

• For the methods, use the JavaBeans naming convention of set and get.

How do you declare an N-Dimensional array using Malloc?

#include <stdlib.h>

int **array1 = malloc(nrows * sizeof(int *));

for(i = 0; i < nrows; i++)

array1[i] = malloc(ncolumns * sizeof(int));

Where is pawsitive methods?

Pawsitive Methods is located in California, USA.

Void in java?

Void is a keyword in Java. It is always used in method declarations. When used in the line that declares a method, it signifies the fact that the method will not return any value. The JVM will not expect the method to return anything.

Ex: public static void main(String[] args) {}

What is a loop tool?

A loop tool is used to smooth and model clay into shape. The tool has a wooden handle and a metal loop at the end that can come in different sizes.

How do you write coding if the grade is between 70 and 100 in Java?

If you mean you want to code this as a condition, you would need to use the AND operator. For example, if your grade is stored in a variable called "grade":

if (grade >= 70 && grade <= 100) {

...

}

What is class hierarchies in java?

The top level class in Java is class Object. Every other class inherits from Object and therefore Object is the top most in the class hierarchy.

If you extend a class from Object such as class Animal and further extend Animal with class Dog then the hierarchy is as follows:

Object

|

Animal

|

Dog

Code for this hierachy is as follows:

class Animal {

}

class Dog extends Animal {

}

We don't need to write class Animal extends Object because every class extends from Object so it does not need to be stated.

How powerful was ENIAC what all could it do?

ENIAC had 20 accumulators each of which could potentially do up to 5000 additions/subtractions per second (this was its total data storage capacity as originally built). To simplify programming it had a multiplier unitthat used 4 accumulators to do multiplications by repeated addition and a divider/square rooter that used 5 accumulators to do division or square roots by repeated subtraction. Programming was done by wiring different units together with cables. With optimal programming speeds of 50000 to 100000 additions/subtractions per second could be achieved in short bursts but were impossible to sustain.

Later upgrades were added including 100 words of magnetic core RAM and a limited form of stored program operation from ROM that reduced the machine to having only one programmer accessible accumulator (the other 19 now had fixed hardware uses that the programmer could not directly control) and a maximum speed of about 800 instructions per second. This reduction in performance was not considered a problem as it dramatically simplified usability and the machine was always throttled in performance by its only input/output devices: one punchcard reader and one punchcard punch each operating at 100 cards per minute (with 8 numbers punched per card).

Its first real problem (taking 2 months to run: December 1945 .. January 1946) was simulation of Edward Teller's first hydrogen bomb design called The Super. The problem used a million punchcards and showed almost immediately that this design could not work and was a dead end. On completion of the run it was obvious that a totally different approach to hydrogen bomb design was needed.

It was a very flexible computer and could do anything a modern computer can, IF the variables of the problem could fit in its limited memory space.

Why do you use hashing and not array?

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Does throws throws only unchecked exception?

You can throw any type of exception you want, including an unchecked exception.