Computer Science, asked by sakshamtrivedi290, 1 month ago

Q7.Rewrite the following program after identifying the errors-

class Program 1

{

void set( )

{

a=5;

b=6;

}

void get( )

{

System.out.println(a+ “ ”+ b);

}

public static void main(String args {} )

{

Program 1 ob = New Program 1( );

ob.get( );

set().ob;

}

}​

Answers

Answered by minetum68
1

Answer:

Fyi9hgg-ggvftfdrifixyu

Answered by devarchanc
0

Program

Explanation:

  • Name of class can not contain spaces. We can only use alphabets, digits, underscore and dollar sign. Any other special character is not used.
  • In the given program, the function void set() is used to initialize value to the variables and void get() is used to print the values of variable.

Correct program is given below:

class Program_1

{

void set( )

{

a=5;

b=6;

}

void get( )

{

System.out.println (a+ “ ”+ b);

}

public static void main(String[] args)

{

Program_1 ob = New Program_1( );

ob.set();

ob.get( );

 0}

}​

Similar questions