A: Definitions and Short Answers i. List the eight primitive data types in Java
ID: 3919766 • Letter: A
Question
A: Definitions and Short Answers i. List the eight primitive data types in Java ii. List the non-access modifiers we have seen in class. Describe what each are used for iii. Briefly describe the entire process of writing a Java program to running in it from the command line. (Be sure to explain what javac and java are and what they do.) iv. In a Java program, why does main need to be public? v. In a Java program, the sain method is static What would be the conseqences if vi. Suppose you have a final array of numbers as an attribute. Explain why you can or vii. Give a concise definition of a method signature. What is the method signature of the vii. What is the difference between a primitive data type and a reference data type in Java? Java did not require this? (i.e, how would you run a program?) cannot change the numbers in the array main method of any program in J ix. Briefly describe the difference between a class attributeand an instance attribute. x. Briefly describe the difference between a class method and an instance method xi. In the statement System.out.println("hello, world!") explain what System out and printin each are. xii. Briefly describe the difference between the stack and the heap in our memory model xiii. Briefly describe the four sections of the memory model discussed in class: stack, heap data segment, code segmentExplanation / Answer
A)
i)
Primitive data types in java: int,float,char,short,long,double,boolean,byte
ii)
Non Access modifiers:
static: for creating class data variables and methods..
final: for finalizing the implementaions of methods,variables and classes
abstract: for creating abstract methods and classes
synchronized and volatile for threading
iii)
Java program
start with class declaration with access modifier as public
then class definition/body..contents and operations, stataments
each statement ends with ;
now...with in the body of the class ..
main method in the following format..
public static void main(String argv[])...
lets see the below example
public class Hello
{
public static void main(String argv[])
{
System.out.println("Hello");
}
};
//now first we need to compiler this
by command
javac Hello.java
now we can run it by
java Hello
iv)
public is access specifier which allows the code to be runned from outside...
since main has to be runned from outside...it need to be public
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.