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.
Why is 1 example of my code failing? def current_player_score(score_one: int, score_two: int,current_player: str) -> int:...
Why is 1 example of my code failing? def current_player_score(score_one: int, score_two: int,current_player: str) -> int: """Return <score_one> if the <current_player> represents player one, or <score_two> if the <current_player> represents player two. >>> current_player_score(2, 4, "Player one") 2 >>> current_player_score(2, 3, "Player two") 3 """ if current_player == PLAYER_ONE: return score_one return score_two
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...
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)
(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?
EXPLAIN ANS PLEASE: PYTHON 1. s = 'abc' print(s[0:] + s[-2:2] + s[:1]) 2. def mirrorOnWheels(s):...
EXPLAIN ANS PLEASE: PYTHON 1. s = 'abc' print(s[0:] + s[-2:2] + s[:1]) 2. def mirrorOnWheels(s): prev = 0 for current in range(1, len(s) - 1): prev = current - 1 next = current + 1 if s[prev] == s[next]: break else: continue return 0 return prev s = 'Good decision!' print(mirrorOnWheels(s)) 3. mixture = {1:[1, 2, 0], 2:[2, 0, 1], 0:[0, 1, 2]} print(mixture[2][2]) 4. noOddHeroes = [] heroes = ['superman', 'batman', 'aquaman'] for hero in heroes: if len(hero)...
def largest_rectangle_in_matrix(matrix: List[List[int]]) -> int: """ Returns the area of the largest rectangle in <matrix>. The...
def largest_rectangle_in_matrix(matrix: List[List[int]]) -> int: """ Returns the area of the largest rectangle in <matrix>. The area of a rectangle is defined as the number of 1's that it contains. Again, you MUST make use of <largest_rectangle_at_position> here. If you managed to code largest_rectangle_at_position correctly, this function should be very easy to implement. Similarly, do not modify the input matrix. Precondition: <matrix> will only contain the integers 1 and 0. >>> case1 = [[1, 0, 1, 0, 0], ... [1,...
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,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT