1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SSSSS [86.1K]
3 years ago
11

Analyze the following code. II: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java

!"); } } Both I and II can compile and run and display Welcome to Java, but the code in II has a better style than I. Only the code in I can compile and run and display Welcome to Java. Only the code in II can compile and run and display Welcome to Java. Both I and II can compile and run and display Welcome to Java, but the code in I has a better style than II.
Computers and Technology
1 answer:
Grace [21]3 years ago
8 0

COMPLETE QUESTION

I. public class Test {

public static void main(String[] args){

System.out.println("Welcome to Java!");

}

}

II. public class Test { public static void main(String[] args) {System.out.println("Welcome to Java!");}}

Answer:

Both codes will compile and run and display Welcome to Java, but the code in II has a better style than I

Explanation:

When written codes, paying attention to proper coding styles and efficient memory management enables us to create programs that are highly efficient, coding styles refer to proper indentions and avoiding too lenghty lines of code (as is in code I), adding approprite comments etc.

You might be interested in
To find your personal learning style you can
JulsSmile [24]
Https://simplelifestrategies.com/sls-learningstyle/ this list may help ypu decide
6 0
3 years ago
Read 2 more answers
Modify the WordCount program so it outputs the wordcount for each distinct word in each file. So the output of this DocWordCount
stepladder [879]

Answer and Explanation:

package PackageDemo;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.LongWritable;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;

import org.apache.hadoop.mapreduce.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import org.apache.hadoop.util.GenericOptionsParser;

public class WordCount {

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

{

Configuration c=new Configuration();

String[] files=new GenericOptionsParser(c,args).getRemainingArgs();

Path input=new Path(files[0]);

Path output=new Path(files[1]);

Job j=new Job(c,"wordcount");

j.setJarByClass(WordCount.class);

j.setMapperClass(MapForWordCount.class);

j.setReducerClass(ReduceForWordCount.class);

j.setOutputKeyClass(Text.class);

j.setOutputValueClass(IntWritable.class);

FileInputFormat.addInputPath(j, input);

FileOutputFormat.setOutputPath(j, output);

System.exit(j.waitForCompletion(true)?0:1);

}

public static class MapForWordCount extends Mapper<LongWritable, Text, Text, IntWritable>{

public void map(LongWritable key, Text value, Context con) throws IOException, InterruptedException

{

String line = value.toString();

String[] words=line.split(",");

for(String word: words )

{

Text outputKey = new Text(word.toUpperCase().trim());

IntWritable outputValue = new IntWritable(1);

con.write(outputKey, outputValue);

}

}

}

public static class ReduceForWordCount extends Reducer<Text, IntWritable, Text, IntWritable>

{

public void reduce(Text word, Iterable<IntWritable> values, Context con) throws IOException, InterruptedException

{

int sum = 0;

for(IntWritable value : values)

{

sum += value.get();

}

con.write(word, new IntWritable(sum));

}

}

}

8 0
3 years ago
List down any 5 Advantages and any 5 Disadvantages of Computers
Dahasolnce [82]

Advantages

Increase your productivity. ...

Connects you to the Internet. ...

Can store vast amounts of information and reduce waste. ...

Helps sort, organize, and search through information. ...

Get a better understanding of data. ...

Keeps you connected. ...

Help you learn and keep you informed. ...

Can make you money.

Disadvantages

Too much sitting. ...

Carpal tunnel and eye strain. ...

Short attention span and too much multitasking. ...

Potential of loss of privacy. ...

Can limit learning and create a dependency. ...

Time sink and lots of distractions....

5 0
2 years ago
Read 2 more answers
Create a class named Employee. The class must contain member variables for the employee name and salary. It should contain gette
Lerok [7]

Answer:

Explanation:

The following code was written in Java. The code contains the Employee class which contains the two variables (name, salary), the constructor, getter and setter methods for both variables, and an overwritten toString method. It also contains a tester class with the main method inside and creates a Employee object and initializes it. Then it calls the toString method. The output can be seen in the attached image below. Due to technical difficulties I have added the code as a txt file below.

8 0
3 years ago
Int[] myArray1= new int[24]; int[] myArray2= new int[10]; float[] myArray3= new float[8]; int index1, index =0 for(int index1 =0
anastassius [24]

Answer:

The value of myArray2[index2] when index1 = 12 is 30

Explanation:

In the source code, the formula for myArray2[index2] is;

   myArray2[index2] = index2 + index3 + myArray1[index1],

   myArray1[index1] = index1 * 2,

   index2 = index % 10 (equal to the remainder) and

   index3  = index % 8

When index1 increases to 12 in the for-loop statement, the "myArray1[index1]" is equal to 24, index2 is equal to 2 and index3 is 4. The total sum is equal to 30 and assigned to "myArray2[index2]".

3 0
3 years ago
Other questions:
  • Please help i really need to turn this in already
    6·1 answer
  • A(n) ________ address is a temporary ip address assigned from an available pool of ip addresses.
    12·1 answer
  • Write a function named times_ten. the function should accept an argument and display the product of its argument multiplied time
    13·1 answer
  • You are building a gaming computer and you want to install a dedicated graphics card that has a fast gpu and 1gb of memory onboa
    15·2 answers
  • The picture that graphically represents the items you use in windows is called a/an
    5·1 answer
  • Which of the following explains the growing need for a standard IT professional licensing program? Check all of the boxes that a
    11·1 answer
  • What is the advantage of maintaining a list of keywords while creating a design blueprint?
    13·2 answers
  • What is the main fuction of command interpreter​
    11·1 answer
  • How will the health care professions be affected by all the computerized and technical advances concerning disabilities?
    9·1 answer
  • Which of the following rules need to be followed when using variables?<br> Choose all that apply.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!