Answer:
//The Employee Class
public class Employee {
char name;
long ID;
//The constructor
public Employee(char name, long ID) {
this.name = name;
this.ID = ID;
}
//Method Get Person
public void getPerson (char newName, long newId){
this.ID = newName;
this.ID = newId;
}
//Method Print
public void print(){
System.out.println("The class attributes are: EmpName "+name+" EmpId "+ID);
}
}
The working of the class is shown below in another class EmployeeTest
Explanation:
public class EmployeeTest {
public static void main(String[] args) {
Employee employee1 = new Employee('a', 121);
Employee employee2 = new Employee('b', 122);
Employee employee3 = new Employee('c', 123);
employee1.print();
employee2.print();
employee3.print();
}
}
In the EmployeeTest class, Three objects of the Employee class are created.
The method print() is then called on each instance of the class.
Answer:B
Explanation:.is cabling that extends out from the work area into the LAN.
Answer:
Explanation:
The system will be deadlock free if the below two conditions holds :
Proof below:
Suppose N = Summation of all Need(i), A = Addition of all Allocation(i), M = Addition of all Max(i). Use contradiction to prove.
Suppose this system isn't deadlock free. If a deadlock state exists, then A = m due to the fact that there's only one kind of resource and resources can be requested and released only one at a time.
Condition B, N + A equals M < m + n. Equals N + m < m + n. And we get N < n. It means that at least one process i that Need(i) = 0.
Condition A, Pi can let out at least 1 resource. So there will be n-1 processes sharing m resources now, Condition a and b still hold. In respect to the argument, No process will wait forever or permanently, so there's no deadlock.
A function that returns Pascal's Triangle with n rows:
//import necessary headers
public class Pascal_Triangle {
// calculate factorial
static int factorial(int n)
{
int fact = 1;
int i;
for(i=1; i<n; i++)
{
fact*=i;
}
return i;
}
// Actual code to display the //pascal triangle
static void display(int n)
{
int i;
int line;
for(line=1;line<=n;line++)
{
for(i=0;i<=line;i++)
{
System.out.print((factorial(line)/factorial(line-i) * factorial(i)) + " ");
}
System.out.println();
}
}
// To read user input
public static void main(String[] args){
BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
int n;
System.out.println("Enter the size for creating Pascal triangle");
try {
n = Integer.parseInt(breader.readLine());
}
catch(Exception e){
System.out.println("Please enter a valid Input");
return;
}
System.out.println("The Pascal's Triangle is");
display(n);
}
}