Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
it is showing error in line 15
demo.java:15: error: ')' expected
                System.out.println(q " "+ w);
                                    ^
demo.java:15: error: not a statement
                System.out.println(q " "+ w);
                                        ^
demo.java:15: error: ';' expected
                System.out.println(q " "+ w);
                                           ^
3 errors


What I have tried:

Java
class demo
{
    int a,b;
    
    demo(int i,int j)
    {
        a=i;
        b=j;
    }
    
    void test(int x,int y)
    {
        int q=0,w=0;
        q=x;w=y;
        q*=10;
        w/=2;
        System.out.println(q " "+ w);
    }
    
    public static void main(String args[])
    {
        demo d = new demo(5,6);
        System.out.println("Previous value are "+ d.a+" and "+d.b);
        d.test(5,6);
        System.out.print(d.a+" "+d.b);
    }
}

According to me the output must be:
5 and 6
50 3
5 and 6
Posted
Updated 13-Sep-17 22:44pm
v4

There's a missing '+'.
Quote:
System.out.println(q " "+ w);
Should be instead
System.out.println(q + " "+ w);
 
Share this answer
 
Java
System.out.println(q " "+ w);

A simple syntax error ...
Java
System.out.println(q + " " + w);
 
Share this answer
 
havent called the method test in your main method
 
Share this answer
 
Comments
Graeme_Grant 14-Sep-17 4:57am    
What is this?
d.test(5,6);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900