/*Create a base class with an abstract print( ) method that is overridden in a derived class.
The overridden version of the method prints the value of an int variable defined in the
derived class. At the point of definition of this variable, give it a nonzero value.
In the base-class constructor, call this method. In main( ), create an object of the derived
type, and then call its print( ) method. Explain the results. */

abstract class print
{
    abstract void print();
}
class p extends print
{
    int p=10;
    void print()
    {
     System.out.println("value of p is "+p);
    }
}
public class a2q2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
     
        p p2 = new p();
        p2.print();
    }
   
}


/*Create a abstract class Vehicle having numberofwheels, sittingcapacity and price as its fields. 4
Derive a  class Car from Vehicle and add modelname and speedlimit details in class Car.
Write appropriate constructors and methods to initialize, modify and display value of attributes.
Modify the above program to create Bike class from Vehicle adding company, mileage and color details
and override the methods (defined in base class) in the derived class.*/



import java.util.Scanner;
public class Vehicle
{
 int n;
 int s;
 int p;
    void getdata()
    {
        Scanner sc =  new Scanner(System.in);
        System.out.println("enter the number of wheels");
        int n1 = sc.nextInt();
          System.out.println("enter the sitting capacity");
        int s1 = sc.nextInt();
          System.out.println("enter the price of the vehicle");
        int p1 = sc.nextInt();
    }
    void display()
    {
        System.out.println("---------------------------");
        System.out.println("wheels pair"+ n);
        System.out.println("sitting capacity : "+s);
        System.out.println("price  :"+p) ;
    }
}
class car extends Vehicle
{
    int m;
    int l;
    void get()
    {
        Scanner sc =  new Scanner(System.in);
        System.out.println("enter the modle number");
        int n1 = sc.nextInt();
          System.out.println("enter the veicle speed limits");
        int s1 = sc.nextInt();
    }
    void disp()
    {
        System.out.println("model number is :  "+m);
        System.out.println("speed limit is : "+l);
    }
class bike extends Vehicle
{
    int  c, mi,cl;
    void get1()
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("enter the bike company");
        int c1= sc.nextInt();
          System.out.println("enter the milegae");
        int mi1= sc.nextInt();
          System.out.println("enter the bike color");
        int cl1= sc.nextInt();
    }
    void disp1()
    {
        System.out.println("bike comapany : "+c);
        System.out.print("mileage of the bike : "+mi);
        System.out.println("enter the bike color : "+cl);
       
    }
}
public class test
{
    private   void  main(String[] args)
    {
        Vehicle v1 = new Vehicle();
        car c1= new car();
        c1.get();
        c1.disp();
   
        v1.getdata();
        v1.display();
        System.out.println("details of the bike");
        bike b1 = new bike();
        b1.get1();
        b1.disp1();
       
    }
}
}
                
Java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf.
To get you started, a portion of the solution is provided for you in the editor; you must format and print the input to complete the solution.
Input Format
Every line of input will contain a String followed by an integer
Each String will have a maximum of 10 alphabetic characters, and each integer will be in the inclusive range from 0 to 999.
Output Format
In each line of output there should be two columns: 
The first column contains the String and is left justified using exactly 15 characters. 
The second column contains the integer, expressed in exactly 3 digits; if the original input has less than three digits, you must pad your output's leading digits with zeroes.
Sample Input
java 100
cpp 65
python 50
Sample Output
================================
java 100
cpp 065
python 050
================================
Explanation
Each String is left-justified with trailing whitespace through the first 15 characters. The leading digit of the integer is the 16th character, and each integer that was less than 3 digits now has leading zeroes.


import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            System.out.println("================================");
            for(int i=0;i<3;i++)
            {
                String s1=sc.next();
                int x=sc.nextInt();
                System.out.printf("%-15s%03d%n", s1, x);
            }
            System.out.println("================================");

    }
}

Most of the problems on HackerRank require reading input from stdin (standard input) and writing output to stdout (standard output).
One way to read from stdin is by using the Scanner class and specifying the InputStream asSystem.in. Alternatively, you can use the BufferedReader class.
Lines of output can be written to stdout with the System.out.println function.
For this exercise, you need to read inputs from stdin and print them to stdout.
Input Format
There are three lines of input.
Line one contains an integer.
Line two contains a double.
Line three contains a String.
Output Format
On the first line, print String: followed by the unaltered input String.
On the second line, print Double: followed by the unaltered input double.
On the third line, print Int: followed by the unaltered input integer.
To make the problem easier, a portion of the code is already provided in the editor.
Note: If you use the nextLine() method immediately following the nextInt() method, recall that nextInt() reads integer tokens; because of this, the last newline character for that line of integer input is still queued in the input buffer and the next nextLine() will be reading the remainder of the integer line (which is empty).
Sample Input
42
3.1415
Welcome to HackerRank Java tutorials!
Sample Output
String: Welcome to HackerRank Java tutorials!
Double: 3.1415
Int: 42
Note: Do not concern yourself with formatting the output at this time; the goal here is to acquaint yourself with stdin and stdout.
Java 7
16
import java.util.Scanner;

public class Solution {

public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
double y = sc.nextDouble();

sc.nextLine();

String s = sc.nextLine();

System.out.println("String: "+s);
System.out.println("Double: "+y);
System.out.println("Int: "+x);
}
}
Using "if-else" you can perform decision making in Java. See the flowchart below (taken from wikipedia):
This problem will test your knowledge on "if-else" statements.
Given an integer N as input, check the following:
  • If N is odd, print "Weird".
  • If N is even and, in between the range of 2 and 5(inclusive), print "Not Weird".
  • If N is even and, in between the range of 6 and 20(inclusive), print "Weird".
  • If N is even and N>20, print "Not Weird".
We given you partially completed code in the editor, complete it to solve the problem.
Input Format
There is a single line of input: integer N.
Constraints 
1N100
Output Format
Print "Weird" if the number is weird. Otherwise, print "Not Weird". Do not print the quotation marks.
Sample Input 1
3
Sample Output 1
Weird
Sample Input 2
24
Sample Output 2
Not Weird
solution
-------------------------------------------------------------------------------
 import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
String ans="";
if(n%2==1){
ans = "Weird";
}
else{

//Complete the code

}
System.out.println(ans);

}
}