Professional Documents
Culture Documents
Assignment 2 “individually”
Student Name:
Q. No
0131 1 d
-------------------------------------------------------------------------------------------------
Q1 3
Q2 3
Q3 4
Total 10
void fun1(void) {
int a, b, c;
void fun2(void) {
int d, e, f;
void fun3(void) {
int c, d, e;
void main () {
int a, f, e;
Given the following calling sequences and assuming that dynamic scoping is used, what
variables are visible during execution of the last function called? Include with each visible
CS430
function sub3() {
var a, x, w;
funcorably
. . . a b cinsubl x xglobalvariablecchidden
3
}
} end main
a y cinsub2 bin sub a chidden
List all the variables, along with the program units where they are declared, that are visible in the
bodies of sub1, sub2, and sub3, (Points 1, 2, and 3)variable
global Hcscoping
assuming static hiddenis used.
2
CS430
Question 3. Given the following Java program
public class Example {
public static int count;
public static void main(String[] args) {
Counter();
void Grade_function() {
int grade1=3.5;
int grade2=5.3;
int total = 0;
String message;
total=grade1+grade2;
System.out.println("count = " + ++count);
message = “The total of student grades “ + “ is “ + total;
System.out.println(message);
}
public static HashSet singleton(Object obj) {
HashSet set;
set = new HashSet();
set.add(obj);
return set;
}
List all static variables, stack-dynamic variables, explicit heap-dynamic variables, and
implicit heap-dynamic variables. new
new b
Static variable Stack Dynamic Explicit Heap Dynamic implicit Heap
Dynamic
3
CS430
delete
of Ctt Lew
C milloc
new
Java