In: Computer Science
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
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.