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

Using function create a program that will ask the user if he wants to compute the perimeter or the area of the triangle in your main program If the perimeter is wanted ask the measures of the three si?

//Perhaps this is what you want.

//@author Rosencrantz

import java.util.Scanner;

class TriangleFun

{

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

boolean done = false;

while(true)

{

System.out.print("Calculate AREA or PERIMETER? Type DONE to quit.");

String input = scan.nextLine().trim();

if(input.equalsIgnoreCase("DONE"))

break;

if(input.equalsIgnoreCase("AREA"))

{

System.out.print("Enter the base length: ");

double base = scan.nextDouble();

System.out.print("Enter the height: ");

double height = scan.nextDouble();

System.out.println("Area is: " + (1/2.0) * base * height);

}

else

{

System.out.print("Enter length of side 1: ");

double length1 = scan.nextDouble();

System.out.print("Enter length of side 2: ");

double length2 = scan.nextDouble();

System.out.print("Enter length of side 3: ");

double length3 = scan.nextDouble();

System.out.println("Perimeter is: " + (length1 + length2 + length3));

}

scan.nextLine();

}

}

}

//A better edited version is in the links

What is java EE 5?

Java is a programming language which comes in many varieties. Some of the common ones are Micro Edition (ME), Standard Edition (SE), and Enterprise Edition (EE).

Java EE includes more classes than the other versions, including classes and packages designed to make developing client-server (and other internet-based communication) projects a faster process.

Java EE 5 just means the fifth major version of the Java EE suite.

What can identify matter?

There are several properties of matter that can help to identify it and can be easily tested or measured. First test for electrical conductivity and thermal conductivity. Also test for magnetism. If the substance is a non powdered solid, then calculate the volume using water and weigh the object to find the density.

Website of free java project to be download with source code?

which Website for free java project to be download with source code

Free Download Project in asp.net,Java ,C#.Net ,Php on thisWebsite www.enggroom.com

What is whitespace?

I read in Maximum PC magazine that white space will be a way for people too get free broadband internet and achieve up to 100mb/s of downloads. But there is a debate that white space will interfere with mikes and speakers in heavy populated areas. But dont be expecting to see this soon. It will probably, my guess, take around 6 to 7 years till its on the market

What are the three types of variables used in java?

Instance, Local and Class variables. They can be prefixed by keywords such as "final" or "transient" to govern the way their values are dealt with in Java. All these variable types have different scopes and visibilites. Locals are specific to a particular area in the code e.g. methods, instances are tied to a particular class and would contain values based on the state of the class at a given point in time and Class variables are like global variables which are independent of the state of the class at any time and as such will contain the same value unless, explicitly changed in the code. These variables are marked by "static" keyword and more often than not prefixed by keyword "final" to prevent programmatic change in the value for e.g. in the case of constant values like PI.

What is character in java?

A character, or char, is single letter such as 'a'.

It's a primitive data type, like int and long, and the letter is always put inside single quotes ' '.

The class String, which is used for storing sentences, is made up of a whole bunch of char's put together.

What does setAutoCommit do?

When a connection is created, it is in auto-commit mode. This means that each individual SQL statement is treated as a transaction and will be automatically committed right after it is executed. The way to allow two or more statements to be grouped into a transaction is to disable auto-commit mode

How methods with multiple parameters are declared?

The same as in C, with a comma-separated list of formal arguments enclosed in parenthesis.

Write a program to print all the prime numbers between n and m in java?

import java.io.*;

public class pmn {

public static void main(String[] args) throws Exception{

int i;

BufferedReader bf = new BufferedReader(

new InputStreamReader(System.in));

System.out.println("Enter number:");

int num = Integer.parseInt(bf.readLine());

System.out.println("Prime number: ");

for (i=1; i < num; i++ ){

int j;

for (j=2; j<i; j++){

int n = i%j;

if (n==0){

break;

}

}

if(i == j){

System.out.print(" "+i);

}

}

}

}

What is data binding in java?

Data binding is basically a technique for binding two data/information sources together and maintaining a synchronization of data.

You usually achieve this with two data/information sources with different languages as in XML data binding or in fact using Java, Java UI elements to Java objects.

How do you convert jar file to sis?

this conversion is not possible

because sis is a symbian file(another operating system that is mainly used by nokia)

&

jar is java file

both are not same

What is the use of switch statement in java?

In java, a switch statement is used to simplify a long list of 'if' statements. A switch statement takes the form of:

switch (variableName){

case condition1; command1;

case condition2; command2;

...

}

My java updates come frequently and use up a lot of memory and i am wondering if there is any way to avoid this?

Do you mean your Java installation keeps updating itself? If this is the case, then you have two options:

  1. Turn off auto-updates for Java and just stick with the version you're using now.
  2. Whenever you see a new version has been installed, uninstall the old versions. (If you have a more recent version, there is little chance of you needing an outdated version, as well).

Is an EUE thread a Non-Pressure sealed thread?

EUE thread is a pressure sealed thread as usual completion pup joints thread

What kinds of members can a class have?

Members of a class may include

1. Static Methods

2. non-static methods

3. Instance variables

4. Sub classes

etc.

Why you are mark a class protected for inheritance?

Public, Private and Protected "keywards/ access modifiers" are used similarly as they are with variables. Protected variables, methods or class CAN ONLY be used by an inherited class.

What method gets a value from a class s field but does not change it?

An accessor method can be used to get a value from a class without changing the value.

How do you add two binary numbers using java code?

public class Exercise6{

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("Example: " + addBinaryNumbers("100", "111")); // Result = 1011

// Test Cases :

// Valid Equivalence Class

// Since the inputs are valid, there will be no errors

assert (addBinaryNumbers("1", "1").equals("10") ) : "Valid Case 1: Error";

assert (addBinaryNumbers("10", "10").equals("100") ) : "Valid Case 2: Error";

assert (addBinaryNumbers("111", "111").equals("1110") ) : "Valid Case 3: Error";

assert (addBinaryNumbers("1110", "1011").equals("11001") ) : "Valid Case 4: Error";

// Invalid Equivalence Class

// Since the inputs are invalid, there will be errors

assert (addBinaryNumbers("2", "3").equals("101") ) : "Invalid Case 1: Error";

}

public static String addBinaryNumbers(String n1, String n2) {

String result = "";

for(int i = 0; i < n1.length(); i++) {

if ( (n1.charAt(i) != '0') && (n1.charAt(i) != '1') ) {

System.out.println("First number is invalid");

}

}

for(int i = 0; i < n2.length(); i++) {

if ( (n2.charAt(i) != '0') && (n2.charAt(i) != '1') ) {

System.out.println("Second number is invalid");

}

}

int number1 = Integer.parseInt(n1, 2);

int number2 = Integer.parseInt(n2, 2);

int resultNumber = number1 + number2;

result = Integer.toBinaryString(resultNumber);

return result;

}

}

What complications are imposed if one tries to implement a dynamic list using a traditional homogeneous array?

in dynamic list after adding a new element size of the list disturbed so deletion and insertation is necessary to add a new element

Explain the four basic data type in C. What is the size in byte of each type in DOS and UNIX platforms?

1. 'Explain' is not a question, but here you are:

unsigned char: a number between 0 and 255

signed char: a number between -128 and 127

unsigned short: a number between 0 and 65535

signed short: a number between -32768 and 32767

2. sizeof (type) will tell you