How does Java prevent invalid memory access?

What will be an ideal response?


Removal of pointer arithmetic is the most important language feature contributing to Java's safety. Pointer arithmetic leads to accessing inappropriate memory areas and unpredictable program behaviors that usually lead to runtime crashes. References are used instead of pointers to allow Java programmers to create data structures such as linked lists, bags, binary trees, or any other programming constructs usually created using pointers in a language such as C or C++. There is also no chance of randomly initialized variables depending on runtime memory. The Java language specification clearly defines the behaviors of uninitialized variables. All heap-based memory is initialized automatically according to the specification. An uninitialized integer always contains zero as value, and an uninitialized string always contains spaces. The javac compiler does not allow any class or instance variable to be set to undefined values. In addition, all local variables must be assigned; otherwise, the javac compiler produces an error and stops the compilation process.

Computer Science & Information Technology

You might also like to view...

Assume that all variables in the following code are properly declared and that the input is 3 7 4 -1. The output is 13.num = console.nextInt();sum = num;while (num != -1){     num = console.nextInt();     sum = sum + num;}System.out.println(sum);

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A(n) ____ is an area on a Web page that contains the links to other pages in a Web site.

a. tween b. slice preview c. navigation bar d. bounding box

Computer Science & Information Technology

Which SATA version supports transfer speeds up to 6 Gb/s?

A. Version 1 B. Version 2 C. Version 3 D. Version 3.2

Computer Science & Information Technology

________ is an assessment solution for identifying vulnerabilities, configuration issues, and malware that attackers use to penetrate networks. It performs vulnerability, configuration, and compliance assessment.

A. Nessus Professional B. Nikto C. Qualys VM D. OpenVAS

Computer Science & Information Technology