Skip to main content

Write a java program to implement multiple inheritance | VCMIT

Multiple Inheritance.


INPUT

interface Car
{
    int speed=60;
    public void distanceTravelled();
}
interface Bus
{
    int distance=100;
    public void speed();
}
public class Vehicle implements Car,Bus
{
    int distanceTravelled;
    int averageSpeed;
    public void distanceTravelled()
    {
        distanceTravelled=speed*distance;
        System.out.println("Total Distance Travelled is : "+distanceTravelled);
    }
    public void speed()
    {
        int averageSpeed=distanceTravelled/speed;
        System.out.println("Average Speed maintained is : "+averageSpeed);
    }
    public static void main(String args[])
    {
        Vehicle v1=new Vehicle();
        v1.distanceTravelled();
        v1.speed();
    }
}

OUTPUT



Comments

// Assuming you have fetched the search query and blog posts // Function to calculate the similarity score between search query and post function calculateSimilarity(query, post) { // You can use a similarity algorithm here, like TF-IDF or cosine similarity // Return a score that represents how relevant the post is to the query } // Function to suggest relevant posts based on search query function suggestPosts(searchQuery, blogPosts) { const suggestedPosts = []; for (const post of blogPosts) { const similarityScore = calculateSimilarity(searchQuery, post); if (similarityScore > 0) { suggestedPosts.push({ post, similarityScore }); } } // Sort the suggested posts based on similarity score suggestedPosts.sort((a, b) => b.similarityScore - a.similarityScore); // Return the sorted list of suggested posts return suggestedPosts.map(item => item.post); } // Example usage const searchQuery = "your search query"; const allBlogPosts = [/* array of your blog posts */]; const suggestedPosts = suggestPosts(searchQuery, allBlogPosts); // Now you can display suggestedPosts to the user