Question

Why main() method is always static, void and public? What is the assignment compatibility and why...

Why main() method is always static, void and public?

What is the assignment compatibility and why is it necessary?

Why floating-point numbers have round-off errors?

What are good programming styles?

Some predefined Classes with mostly static methods and purposes of some of these methods.

Commonly used String Class methods.

What are trade-offs between ifstatements and switchstatements?

What operators have Right-to-Left Associativity?

What are expression side effects and what are their trade-offs?

What is the difference(s) between while loops and do-while loops?

What are differences/similarities between break statements andcontinue statements?

What are common loop errors and what are their most probable causes?

What are primary purposes of local variables and where inside your programs can they appear?

How does call-by-value(parameter transmission) mechanism work and when is it used?

What is the this parameter and when can it be omitted and when should it be required?

What are some good tools for Information Hiding?

What are static methods and what are their trade-offs?

What are differences between primitive parameters and Class parameters?

What are Copy Constructors and why are they useful?

Compare selectionSort and bubbleSort.

Compare recursion and iteration.

What happens if the < operator is replaced by the == operator on the line-30, Display-6.11, Page 390 and why?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1. This is necessary because main() is called by the JVM before any objects are made. Since it is static it can be straightforwardly summoned via the class. Similarly, we utilize static at some point for client characterized methods so we require not to make objects. void indicates that the main() method is declared does not return a value.

Answer 3. This is because a few fractions require a large (or even unbounded) amount of places to be communicated without adjusting. This remains constant for decimal notation as much as for binary or any other. In the event that you would confine the number of decimal places to use for your calculations (and avoid making calculations in fraction notation), you would have to round even a straightforward expression as 1/3 + 1/3. Instead of composing 2/3, therefore, you would have to compose 0.33333 + 0.33333 = 0.66666 which isn't identical to 2/3.

In case of a PC, the quantity of digits is constrained by the technical nature of its memory and CPU registers. The binary notation utilized internally adds some more troubles. PCs normally can't express numbers in fraction notation, however, some programming languages add this ability, which allows those issues to be avoided to a certain degree.

Answer 10. The while loop checks the condition at the starting of the loop and if the condition is satisfied statement inside the loop, is executed. In the do-while loop, the condition is checked after the execution of all statements in the body of the loop.

In the event that the condition in a while loop is false not a solitary statement inside the loop is executed, and if the condition in 'do-while' loop is false then also the body of the loop is executed at least once then the condition is tried.

Answer 19. Copy constructor creates another question of the same class utilizing a current protest. It creates a copy/replica of the current protest.

It duplicates value of all part variables from existing article to new protest. It duplicates values part-to-part.

It will be called when:

At the point when a protest is built based on another question of the same class.

At the point when a question of the class is passed (to a capacity) by value as an argument.

At the point when a question of the class is returned by value.

At the point when the compiler generates a temporary protest.

Copy constructors are important for incredible same reasons as a regular constructor would be, and that is to legitimately initialize the developed protest. Development isn't always trivial, and it doesn't make a difference where do you take the data from and in what frame - other question of the same class or an arrangement of less complex arguments.

In this way, the copy constructor is there to take care of issues like initializing const fields, yet in addition when you utilize pointers, to choose responsibility for the pointed asset. You may want to share or duplicate the data.

Add a comment
Know the answer?
Add Answer to:
Why main() method is always static, void and public? What is the assignment compatibility and why...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • in java Part 1 In this section, we relook at the main method by examining passing...

    in java Part 1 In this section, we relook at the main method by examining passing array as parameters. Often we include options/flags when running programs. On command line, for example, we may do “java MyProgram -a -v". Depending on options, the program may do things differently. For example, "a" may do all things while "-v" display messages verbosely. You can provide options in Eclipse instead of command line: "Run ... Run Configurations ... Arguments". Create a Java class (Main.java)....

  • 1. Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Thread t = new Thread(this); t.start(); } public void run() { System....

    1. Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Thread t = new Thread(this); t.start(); } public void run() { System.out.println("test"); } } 1. The code compiles but will not print anything since t does not invoke the run method. 2. The code will not compile since you cannot invoke "this" in a static method. 3. The program compiles, runs, and prints tests on the console. 2. What will the following example...

  • Submit Chapter6.java with a public static method named justifyText that accepts two parameters; a Scanner representing...

    Submit Chapter6.java with a public static method named justifyText that accepts two parameters; a Scanner representing a file as the first parameter, and an int width specifying the output text width. Your method writes the text file contents to the console in full justification form (I'm sure you've seen this in Microsoft Word full.docx ).  For example, if a Scanner is reading an input file containing the following text: Four score and seven years ago our fathers brought forth on this...

  • DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say f...

    DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say func(), alone, as in x-func) without dereferencing it using prepended name like modname.func or x = some object. func () or x-SomeClass.func() O func) is defined in some module, say, "modname.py" and modname is imported into my_program.py using: from modname import func() is an instance method or a class method in a class, say SomeClass, defined in the same...

  • JAVA Write a public class call FunnyWord. class FunnyWord must have a main method. what it...

    JAVA Write a public class call FunnyWord. class FunnyWord must have a main method. what it does: 0. prompt user for a String 1. read a String from the user 2. print whether the String is funny or not 3. continue until user enters the word "end" The String is funny if it looks the same read from left to right or right to left. In order to pass all tests you must find funny phrases when spaces, punctuation and...

  • 1. Specification For this assignment, write a static class named ShortestRoute to find the shortest route...

    1. Specification For this assignment, write a static class named ShortestRoute to find the shortest route between San Francisco to New York City. (What makes it "static" is that all its members will be static.) The class will include two static recursive functions -- the first is simple, and just finds a valid route through the network, without regards to shortest distance. The second finds the shortest route. Both are explained below. 2. Create A Network Create a constant array...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java...

    I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java Programming Project #4 – Classes and Objects (20 Points) You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent.Here is the list: Shirt Shoe Wine Book Song Bicycle VideoGame Plant Car FootBall Boat Computer WebSite Movie Beer Pants TVShow MotorCycle Design First Create three (3) UML diagrams...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT