Using inheritance, one class can acquire the properties of others. Consider the following Animal class:
class Animal{
void walk(){
System.out.println("I am walking");
}
}
This class has only one method, walk. Next, we want to create a Bird class that also has a fly method. We do this using extends keyword:
class Bird extends Animal {
void fly() {
System.out.println("I am flying");
}
}
Finally, we can create a Bird object that can both fly and walk.
public class Solution{
public static void main(String[] args){
Bird bird = new Bird();
bird.walk();
bird.fly();
}
}
The above code will print:
I am walking
I am flying
This means that a Bird object has all the properties that an Animal object has, as well as some additional unique properties.
The code above is provided for you in your editor. You must add a sing method to the Bird class, then modify the main method accordingly so that the code prints the following lines:
I am walking
I am flying
I am singing
Using inheritance, one class can acquire the properties of others. Consider the following Animal class:
class Animal{
void walk(){
System.out.println("I am walking");
}
}
This class has only one method, walk. Next, we want to create a Bird class that also has a fly method. We do this using extends keyword:
class Bird extends Animal {
void fly() {
System.out.println("I am flying");
}
}
Finally, we can create a Bird object that can both fly and walk.
public class Solution{
public static void main(String[] args){
Bird bird = new Bird();
bird.walk();
bird.fly();
}
}
The above code will print:
I am walking
I am flying
This means that a Bird object has all the properties that an Animal object has, as well as some additional unique properties.
The code above is provided for you in your editor. You must add a sing method to the Bird class, then modify the main method accordingly so that the code prints the following lines:
I am walking
I am flying
I am singing
Write a Java method to check whether a string is a valid password.
Password rules:
A password must have at least ten characters.
A password consists of only letters and digits.
A password must contain at least two digits.
Expected Output:
1. A password must have at least ten characters.
2. A password consists of only letters and digits.
3. A password must contain at least two digits
Input a password (You are agreeing to the above Terms and Conditions.): abcd1234
Password is valid: abcd1234
We want make a package of goal kilos of chocolate. We have small bars (1 kilo
each) and big bars (5 kilos each). Return the number of small bars to use, assuming
we always use big bars before small bars. Return -1 if it can't be done.
makeChocolate(4, 1, 9) → 4
makeChocolate(4, 1, 10) → -1
makeChocolate(4, 1, 7) → 2
Skeleton of the method you should use to return the number:
public int makeChocolate(int small, int big, int goal) {
}
Create a class named Vehicle with instance variables make (String type), color (String type), year ( integer type) and model ( String type). All the variables have default access behaviour. Vehicle class also contains a constructor with four parameters to initialize the make, color, year and model of a specific Vehicle object.
Vehicle class also has a method named printDetails() with return type void and default access to show the output of make, color, year and model of a specific Vehicle object.
Create another class named Car that inherits Vehicle class. Car class has a private instance variable called bodyStyle (String type). The Car class also should have a constructor with five parameters. Now create the main class named Main. Inside the main method of the Main class create an object of Car class by calling the Car class constructor. Then call the printDetails() method using the created object. Finally also output body style of the Car object.
ACME Green is a huge, strategic project across all the companies in the ACME Technologies group.
Tshepo knows that technology will not be the only aspect he will need to manage well for the
project to be successful – he also needs the right people.
List five types of users that would be using the operational carbon accounting database and
explain what the responsibility of each type of user will be in ACME Technologies.
Problem Statement: You work in XYZ Corporation as a Data Analyst. Your corporation has told you to visualize the mtcars.csv dataset with various plots.
1. Plot the area chart for the colmns: ‘am’ and ‘carb’.
a. Set the ‘am’ on the x-axis.
b. Set the ‘carb’ on the y-axis.
c. Provide the x-axis label as Transmission.
d. Provide the y-axis labe as Number of carburetors.
e. Provide the title as Transmission vs Number of carburetors.
Problem Statement: You work in XYZ Corporation as a Data Analyst. Your corporation has told you to analyze the customer_churn dataset with various functions.
1. Now from the churn data frame, try to sort the data by the tenure column according to the descending order.
2. Fetch all the records that are satisfying the following condition:
a. Tenure>50 and the gender as ‘Female’.
b. Gender as ‘Male’ and SeniorCitizen as 0.
c. TechSupport as ‘Yes’ and Churn as ‘No’.
d. Contract type as ‘Month-to-month’ and Churn as‘Yes’
Problem Statement: You work in XYZ Corporation as a Data Analyst. Your corporation has told you to analyze the customer_churn dataset with various functions
1. Now select the rows from 20th index till 200th index (exclusive), and columns from 2nd index till 15th index value
Problem Statement: You work in XYZ Corporation as a Data Analyst. Your corporation has told you to analyze the customer_churn dataset with various functions.
1. Display the top 100 records from the original data frame.
2. Display the last 10 records from the data frame.
3. Display the last record from the data frame
3.Create a function that concatenates two dataframes. Use previously created function to create two dataframes and pass them as parameters Make sure that the indexes are reset before returning:
4. Write code to load data from cars.csv into a dataframe and print its details. Details like: 'count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max'.
5. Write a method that will take a column name as argument and return the name of the column with which the given column has the highest correlation. The data to be used is the cars dataset. The returned value should not the column named that was passed as the parameters.
E.G: get_max_correlated_column('mpg')
-> should return 'drat'
Problem Statement:
You work in XYZ Company as a Python. The company officials want you to build a python program.
1. Write a function that takes start and end of a range returns a Pandas series object containing numbers within that range. In case the user does not pass start or end or both they should default to 1 and 10 respectively. eg. range_series()
-> Should Return a pandas series from 1 to 10 range_series(5)
-> Should Return a pandas series from 5 to 10 range_series(5, 10)
-> Should Return a pandas series from 5 to 10.
2. Create a function that takes in two lists named keys and values as arguments. Keys would be strings and contain n string values. Values would be a list containing n lists.
The methods should return a new pandas dataframe with keys as column names and values as their corresponding values e.g.
-> create_dataframe(["One", "Two"], [["X", "Y"], ["A", "B"]]) -
> should return a dataframe One Two 0 X A 1 Y B