Question

In: Computer Science

Qno.1 Part(A). IN jAVA if 1.Int abc; 2. Int def = 8; 3. abc = def;...

Qno.1 Part(A).

IN jAVA if

1.Int abc; 2. Int def = 8; 3. abc = def; ➢ Describe the procedure how much memory will be allocated when these three lines of codes will execute. ➢ Describe what will happened after execution of each of these line of code in term of memory allocation and data storage

Qno.1 Part(B)

A capacitor is constructed from two conductive metal plates 30cm x 50cm which are spaced 6mm
apart from each other, and uses dry air as its only dielectric material. Calculate the capacitance of
the capacitor using following formula.
C = (die-electric permittivity * Area of plates) / distance between plates
Note: The die-electric permittivity of dry air is 8.84 x 10-12
➢ Write a java program that can calculate the capacitance of any capacitor if we provide it
area of plates, distance between plates and die-electric permittivity of the die-electric.

NOTE:DO ANSWER BOTH PARTS..SOLVE PART (A) IN JAVA THEN PASTE IT HERE AND FOR PART (B) JUST WRITE THE ANSWER

Solutions

Expert Solution

Part A:

1. Total of 12 bytes will be allocated to the 3 variables(primitive) with 4bytes to each variable.

2. 3 variables will be allocated memory of 4 bytes and will have their respective stored in them in Stack.

Part B:

1. Answer : 0.220nF (nF -> nano Farad)

2. Find the code below,

import java.util.*;

public class CapacitanceCalc {

    //Write a java program that can calculate the capacitance of any capacitor if we provide it
    //area of plates, distance between plates and die-electric permittivity of the die-electric.
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        System.out.println("Enter Area of plates (in meters): ");
        double areaOfPlates = sc.nextDouble();
        System.out.println("Enter distance b/w plates (in meters): ");
        double distanceBwPlates = sc.nextDouble();
        System.out.println("Enter die-electric permittivity of the die-electric : ");
        double permittivity = sc.nextDouble();

        double capacitance = (permittivity * areaOfPlates)/distanceBwPlates;
        System.out.println("Capacitance : "+ capacitance);
    }
}

OUTPUT with PartB (1) question:

If you have any doubts put in the comments. Also, do upvote the solution.


Related Solutions

In Java: int[] A = new int[2]; A[0] = 0; A[1] = 2; f(A[0],A[A[0]]); void f(int...
In Java: int[] A = new int[2]; A[0] = 0; A[1] = 2; f(A[0],A[A[0]]); void f(int x, int y) { x = 1; y = 3; } For each of the following parameter-passing methods, saw what the final values in the array A would be, after the call to f. (There may be more than one correct answer.) a. By value. b. By reference. c. By value-result.
Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int...
Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int n, int k)             if (n <= 0) return 0;             else if (A[n] < k) return (1+ 2*BBOX(n-1,k+1));             else return BBOX(n-1,k-2);             Find BBOX(8, 5)
Use Java for the following; Part 1 n!= n * (n –1)* (n–2)* ...* 3 *...
Use Java for the following; Part 1 n!= n * (n –1)* (n–2)* ...* 3 * 2 * 1 For example, 5! = 5 * 4 * 3 * 2 * 1 = 120 Write a function called factorial that takes as input an integer. Your function should verify that the input is positive (i.e. it is greater than 0). Then, it should compute the value of the factorial using a for loop and return the value. In main, display...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6};...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6}; and we also have a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6, where 1 is the first in the linked list L, followed by 2 etc. We want to put a new item 4 between 3 and 5 in the array a and in the linked list L (a) Explain in plain English how you do...
(JAVA) InvertArrangement +invert(int[] a) : int [] +print(int[] a) : void Example 1: the invert method...
(JAVA) InvertArrangement +invert(int[] a) : int [] +print(int[] a) : void Example 1: the invert method receives the following arrangement: [1,2,3,4,5] The invert method returns the array [5,4,3,2,1] Example 2: the print method receives the following array: [5,4,3,2,1] The print method prints: 5,4,3,2,1 (data separated by commas). TIP: for the print method use System.out.print () without the "ln".
Java try and catch problem public void method1(){ int[] array = new int[1]; try{ array[2] =...
Java try and catch problem public void method1(){ int[] array = new int[1]; try{ array[2] = 0;} catch(ArithmeticException e){array[2] = 0} // ? finally{ return 0;}} Could you please tell me why the line with the question mark will not report an error?
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5,...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5, 6, 7, 8}; bArray = aArray; System.out.print(bArray[2]); 1 points    QUESTION 6 What is printed? public static void main(String[] args) { int[] aArray = { 1, 2, 3, 4 }; System.out.print(aArray[2]); int i = aMeth(aArray); System.out.print(i + "" + aArray[2]); } public static int aMeth(int[] iArray) { for (int i = 0; i < iArray.length; i++) { iArray[i]++; } int[] bArray = { 5,...
from partition import partition def quicksort(a: list, l: int, u: int) -> None: '''Sort the given...
from partition import partition def quicksort(a: list, l: int, u: int) -> None: '''Sort the given list a in non-descending order. Precondition: 0 <= l and u < len(a)''' if l < u: mid = (l + u) // 2 three = [a[l], a[mid], a[u]] three.sort() if three[1] == a[l]: pivot_loc = l elif three[1] == a[u]: pivot_loc = u else: pivot_loc = mid a[u], a[pivot_loc] = a[pivot_loc], a[u] pivot = a[u] i = partition(a, l, u - 1, pivot)...
JAVA JAVA JAVA JAVA, My array has 1000 int variables with random values from 1-100, I...
JAVA JAVA JAVA JAVA, My array has 1000 int variables with random values from 1-100, I want to be able to scan and output which number appears the most and the least. int x =1000 int[] array = new array[x] for(int i = 0 ; i < x; i++){ array[i] = random.nextInt(101); }
1. ABC Corporation receives $10,000 dividend income from its equity investment in DEF Corporation. ABC is...
1. ABC Corporation receives $10,000 dividend income from its equity investment in DEF Corporation. ABC is in the 34% marginal tax bracket. The tax on dividend income would amount to: a. $900 b. $3,000 c. $1,020 d. $3,400 2. ABC Corporation’s revenue from sales is $250,000; its COGS is $100,000; its SG&A is $50,000; its interest expense is $20,000; it pays $20,000 as cash dividends. How much is the firm’s income taxes? (Corporate marginal tax rate is $0-50,000: 15%; $50,000-75,000:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT