Question

Somebody help my assignment! CS21, Java -Chapter 1 Quiz –MCTF Know the definitions of the following:...

Somebody help my assignment!

CS21, Java -Chapter 1 Quiz –MCTF


Know the definitions of the following:

•Compiler

•Bytecode

•Console Window

•Syntax Error

•Logic Error

•Runtime Error

Know the rules that apply to string literals

Know if the name of a Java file and the name of a Java class have to be the same

Know if methods other than main are allowed to call other methods

Know where the flow of control goes when a method finishes executing

Know what data is contained in files with extensions .java and .class

Know what characters are allowed as the first character of an identifier

Know all escape sequences

Know what the following keywords mean:

•public

•static

•void

•main

Know what symbols are used for each of the following:

•Contain methods within a class

•Contain code within a method

•Terminate a line of code

•Contain a string literal

•Indicate single-line comments

•Contain multiple-line comments

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

Compiler

Basically compilers are used just like translators. In JAVA the compiler takes the source file and convert it into a platform independent JAVA file. The output of the compiler is a JAVA class file which having JAVA bytecodes.

ByteCodes

          In a single line we can define the bytecode as the instruction set of the Java Virtual Machine. For JAVA bytecode act like an assembler. It gets generated after compilation. In other words we can also define bytecode as the machine codes in the form of (.class) file. These are platform independent codes.

Console Window

          Console window is a platform or area that you get when executing the command cmd.exe on run. By using console window we can compile and execute the java programs.

Syntax Error

          These errors occurs due to avoidance of syntax, while writing the statements or functions in a program. When syntax error occurs then we will be unable to execute the program.

Logical Error.

          These errors will not stop execution of a program. These will result wrong or unexpected output or may lead to infinite loop(If any logical error occur in loops). These cannot be identified by compiler or JVM.

Runtime Error

          As the name suggests these errors occur during the execution time. These errors can not be detected by compiler rather JVM can detect. These are also called as Exceptions.

Rules Applied to String Literals

          The string literals always enclosed within double quotation marks. In JAVA strings can also be represented by using Unicode characters.

Know if the name of a Java file and the name of a Java class have to be the same

        In JAVA the class name and file name must be same if the class is public. It provides the path to JVM as an entry point to execute the program. Because in a program we may use number of classes which may leads to confusion. If the class is not public then we may use different file name.

Know if methods other than main are allowed to call other methods.

          If methods other than main are allowed to call other methods then the method in which other methods are called, it must be called inside the main() method.

Know where the flow of control goes when a method finishes executing

          After execution of a method the control will move to the block from where the method was called.

Know what data is contained in files with extensions .java and .class

The .JAVA file consists of the source code that the programmer have written but the .class file consists of the bytecodes.

Know what characters are allowed as the first character of an identifier

All the alphabets as a…z or A…Z

Underscore is allowed as a first character.

Digits are not allowed as first character.

Know all escape sequences

          Escape sequences are preceeded by backslash(\) and having a specific meaning. Certain non printable characters can be printed by using escape sequences.

\t

Inserts a tab.

\b

Inserts a backspace.

\n

Inserts a newline .

\r

Inserts a carriage return.

\f

Inserts a form feed

\'

Inserts a single quote .

\"

Inserts a double quote character .

\\

Inserts a backslash character

Meaning of

Public: It is an access specifier. It allows the methods or members to access globally. In JAVA main() is declared as public because JVM can access it from outside the class as it is not present in the current class.

Static:

            Static keyword makes a method as a class related method.The main() method is static so that JVM can invoke it without instantiating the class.

Void

This keyword is used when a method does not return any thing. It is basically used in main() method since it will not return anything.

Main

“main” is not a keyword. It is the name of Java main method. It is the identifier that the JVM will start the execution from this.

Symbols used

Contain methods within a class

A pair of curly braces {} are used to provide the methods with in a class after the name of class.

Contain code within a method

A pair of curly braces {} are used to provide the codes within a method after the name of method with return type and arguments(if any).

Terminate a line of code

Semicolon(;) is used to terminate a line of code.

Contain a string literal

Double quotation symbol is used for string literals

Indicate single-line comments

// is used for single line of comments

Contain multiple-line comments

/* comments*/ is used for multiple line comments.

Add a comment
Know the answer?
Add Answer to:
Somebody help my assignment! CS21, Java -Chapter 1 Quiz –MCTF Know the definitions of the following:...
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
  • would someone please kind enough to help me out on my intro to java study guide...

    would someone please kind enough to help me out on my intro to java study guide by helping me with some useful tips/ examples or anything on these questions. My grade is on the line and would really appreciate your help! Final exam study guide 13. truncating vs rounding - Where do you encounter truncation? Where do you encounter rounding? 14. Can you identify the following items in a Java source code example (using just syntax, usage, and naming convention)?...

  • Comments used to document code should: A. be used as little as possible B. be insightful...

    Comments used to document code should: A. be used as little as possible B. be insightful and explain what the instruction's intention is C. only be included in code that is difficult to understand D. be used to define variables whose names are not easy to understand E. not be included with the program 2 points    QUESTION 2 The main method for a Java program is defined by: A. public static main( ) B. public static main(String[ ] args);...

  • JAVA QUESTION 1 The value returned by a value-returning method can be saved for further calculation...

    JAVA QUESTION 1 The value returned by a value-returning method can be saved for further calculation in the program. True False QUESTION 2 To use a predefined method you must know the code in the body of the method. True False QUESTION 3 A formal parameter is a variable declared in the method heading (ie. it's signature). True False QUESTION 4 A local identifier is an identifier that is declared within a method or block and that is visible only...

  • The following class contains several errors that violate the rules of Java: class Part ( private...

    The following class contains several errors that violate the rules of Java: class Part ( private int number: private String name: private int quantity: public Part (int number, String name, int quantity) { this.number = number: this.name = name: this quantity = quantity: } public Part (int number, string name) { this (number, name, 0): } public Part () { this (0, 'No name'): } public void decreaseQuantity(int amount) { quantity = -amount: } public int getName () { return...

  • In java write a command-line program that helps to decrypt a message that has been encrypted...

    In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2). When your...

  • help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with...

    help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with Project Name BasePlusCommission Employee Test with Create Main Class check box selected. Create comments to form a descriptive header that has the course name, your name, the assignment title, and a pledge that you have neither received nor provided help to any person. Assignments submitted without this pledge will not be graded. When you have completed the steps (b) and (c) below, you will...

  • Prelab Exercises Your task is to write a Java program that will print out the following...

    Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. //...

  • Part III. Common String Errors The following two example programs demonstrate common errors that often occur...

    Part III. Common String Errors The following two example programs demonstrate common errors that often occur when programming with Strings. public class StringErrors1 {     public static void main(String [] args) {       String greeting = "hello world";       greeting.toUpperCase();       System.out.println(greeting);     } } Type above code in Dr. Java or Eclipse. Compile and run the program a few times. What does this program do? How might you make the program more user-friendly? Now run the program two more...

  • Using loops with the String and Character classes. You can also use the StringBuilder class to...

    Using loops with the String and Character classes. You can also use the StringBuilder class to concatenate all the error messages. Floating point literals can be expressed as digits with one decimal point or using scientific notation. 1 The only valid characters are digits (0 through 9) At most one decimal point. At most one occurrence of the letter 'E' At most two positive or negative signs. examples of valid expressions: 3.14159 -2.54 2.453E3 I 66.3E-5 Write a class definition...

  • What is wrong with the following Java Code. public class TestEdible { abstract class Animal {...

    What is wrong with the following Java Code. public class TestEdible { abstract class Animal { /** Return animal sound */ public abstract String sound(); } class Chicken extends Animal implements Edible { @Override public String howToEat() { return "Chicken: Fry it"; } @Override public String sound() { return "Chicken: cock-a-doodle-doo"; } } class Tiger extends Animal { @Override public String sound() { return "Tiger: RROOAARR"; } } abstract class Fruit implements Edible { // Data fields, constructors, and methods...

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