Question

JAVA basic quiz.1. a) In order to run a java program, the computer must first compile the .java files to create .class files. Then the Java V

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

1.a) i) The Java bytecode or Java classes are compiled to machine code and loaded into memory by the Java Virtual Machine for the first time.

a) ii)An instance is a specific realization of any object in OOP.The creation of instance is known as instantiation.An object varied in number of ways.Each realized variation of the object is instance.Each time when a program runs,it is an instance of program

Objects are created by constructor and it gets destroyed by destroyer.

Instantiation done by using new keyword.

Syntax:className objName=new className(input parameters)

a)III) when object is no longer in usage then garbage collector reclaims it's memory and reuse it for future memory allocation.Hence as long as object is in usage, they stay in memory.

a) iv)In java as soon as object has no longer any references,it becomes eligible for deletion.Once the object is no longer referenced and therefore it is not reachable by application code,the garbage collector removes and reuse the unused memory.

2.The class is defined as a blueprint or template that describes the behavior or state of an object.

It has main components like variable,method and constructor in java.

Syntax: <access specifier> class className{

// Class body

}

Accessibility Modifiers:

Java provides access through priavte,public and protected.

Private

It is specified with keyword private.It is accessible only within the class in which it is declared.Anyother class of same object will not be able to access.

Protected

It is specified with protected keyword.The method or datamember declared protected are accessible within same package or subclass in different package.

Public

It is specified with public keyword.It can be accessed from everywhere in the program i.e widest scope among all other access Modifiers.

Non-standard accessibility modifier:

  • Java provide non access Modifiers to achieve many functionalities.
  • The static modifier is for creating class methods and variables
  • The final modifier is for finalizing the implementation of classes,methods and variables.
  • The abstract modifier is for creating abstract classes and methods.
  • Synchronized and volatile modifiers are used for thread concepts
Add a comment
Know the answer?
Add Answer to:
JAVA basic quiz. 1. a) In order to run a java program, the computer must first...
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 happens in the Java Virtual Machine (JVM) when the following line is processed? MyClass...

    1. What happens in the Java Virtual Machine (JVM) when the following line is processed? MyClass n = new MyClass(); A. Nothing, the line is skipped, since no parameters are defined B. An object of type MyClass is created, no reference is created C. A reference to an object of type MyClass is created, no object is created D. Both a reference and an object of type MyClass are created 2. Which of the following is true? A. A single...

  • Question 1 1 pts Which of the following is not a valid class name in Java?...

    Question 1 1 pts Which of the following is not a valid class name in Java? O MyClass MyClass1 My_Class MyClass# Question 2 1 pts Which of the following statements is False about instance variables and methods? Instance variables are usually defined with private access modifier. Instance variables are defined inside instance methods. Instance methods are invoked on an object of the class that contains the methods. A class can have more than one instance variables and methods. Question 3...

  • Write a complete Java program to create three types of counters as follows: The first counter...

    Write a complete Java program to create three types of counters as follows: The first counter increases its value by one. The second counter increases its value by two. The third counter increases its value by three. Please follow these notes: Create one class for all counter types. The name of the class is Three_type_counter. Define a constructor method that initial values for all counters to 7 when the class object created. Create method for each counter as: count1, count2...

  • Creating a Shell Interface Using Java This project consists of modifying a Java program so that...

    Creating a Shell Interface Using Java This project consists of modifying a Java program so that it serves as a shell interface that accepts user commands and then executes each command in a separate process external to the Java virtual machine. Overview A shell interface provides the user with a prompt, after which the user enters the next command. The example below illustrates the prompt jsh> and the user’s next command: cat Prog.java. This command displays the file Prog.java on...

  • JAVA PROGRAM USING ECLIPSE. THE FIRST IMAGE IS THE INSTRUCTIONS, THE SECOND IS THE OUTPUT TEST...

    JAVA PROGRAM USING ECLIPSE. THE FIRST IMAGE IS THE INSTRUCTIONS, THE SECOND IS THE OUTPUT TEST CASES(WHAT IM TRYING TO PRODUCE) BELOW THOSE IMAGES ARE THE .JAVA FILES THAT I HAVE CREATED. THESE ARE GeometircObject.Java,Point.java, and Tester.Java. I just need help making the Rectangle.java and Rectangle2D.java classes. GeometricObject.Java: public abstract class GeometricObject { private String color = "white"; // shape color private boolean filled; // fill status protected GeometricObject() { // POST: default shape is unfilled blue this.color = "blue";...

  • **Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of...

    **Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of your own design. The class should contain a protected int member variable var, which is initialized with an integer value between 1 and 50 in a constructor that takes an integer parameter. The class should contain a public member function called playthat should print out a sequence of integers as a result of iteratively applying a math function f to the member variable var...

  • Java - Object lifecycle and memory management Consider the following Java programs: Program Code publ ic cl ass A a pub...

    Java - Object lifecycle and memory management Consider the following Java programs: Program Code publ ic cl ass A a publ ic st at ic voi d mai n( St ri ngl1 args) t hr ows Excepti on whi I e (true) for (i nt i -0 ; i <1000000; i ++) Cbj ect obj new Obj ect ); gi ve JVM 100ms ti me to run gar bage col l ect i on Thr ead. sl eep( 100): i...

  • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

    1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

  • 1. Employees and overriding a class method The Java program (check below) utilizes a superclass named...

    1. Employees and overriding a class method The Java program (check below) utilizes a superclass named EmployeePerson (check below) and two derived classes, EmployeeManager (check below) and EmployeeStaff (check below), each of which extends the EmployeePerson class. The main program creates objects of type EmployeeManager and EmployeeStaff and prints those objects. Run the program, which prints manager data only using the EmployeePerson class' printInfo method. Modify the EmployeeStaff class to override the EmployeePerson class' printInfo method and print all the...

  • 1.     When a sub class object is created, when is the call to the super class...

    1.     When a sub class object is created, when is the call to the super class constructor made? How does a programmer call the super class constructor from the sub class? What do all classes indirectly extend? What methods does every class inherit from the Object class? 2.     When writing methods in a sub class, how can those methods call the methods from the parent class? 3.     Which class is more specific, a super class or a sub class? 4.    ...

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