which of the following can be used in a Java program as iden
Solution
1)
AnnualSalary
ABC
sum_of_data
average
B4
______________________
2)
1)The should\'nt be space in the class name.
2)we have to write mention the return type.( public static void main(String args[]) )
3)In the word String \'S\' must be capital letter.
4)In the word System \'S\' must be capital letter.
5)We have to write the data to print inside the double quotes
System.out.println(\"and enter\");
6) The program should have balanced closing curly braces for the opened braces.
__________________________
3)
Output:
Inside first method
Inside third method
Inside second method
Inside third method
_________________________
4)
order of precedence is
multiplication
division
modulas
addition
subtraction
a) 2 + 3 * 4 - 6 = 2 + (3 * 4) - 6 = 2+12-6=(2+12) - 6=14 - 6 = 8
b)(18-7) * (43%10)
As we already having curly braces.So the priority is more for contents inside it.
(18-7) * (43%10) = 11 * 3 = 33
c)
6 / 2 + 7 / 3 = 3+2=5
______________
5)
24 1
22 2
19 3
15 4
10 5
___________________
6)
The immediate line after the for loop line will be executed for 3 times as we didnt proved the flower brackets
So the Output is:
How many lines
How many lines
How many lines
are printed
______________________
7)
Output:
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
8)
Output:
for(int i=0;i<10;i++)
{
System.out.print((1+3*i)+\" \");
}
______________________
9)
for(int i=1;i<=7;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i);
}
System.out.println();
}
____________________
10)
package org.students;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
String str;
int num;
Scanner sc=new Scanner(System.in);
System.out.print(\"Enter the String :\");
str=sc.next();
System.out.print(\"Enter the no of repetitions :\");
num=sc.nextInt();
printStrings(str,num);
}
private static void printStrings(String str, int num) {
for(int i=0;i<num;i++)
{
System.out.print(str);
}
}
}
______________
Output:
Enter the String :hello
Enter the no of repetitions :6
hellohellohellohellohellohello
_______________________
11)
a)1.6
b)2
c)36
d)64
e)8
f)10+7-8+5=14
_______________________
I will do remaining also


