CBSE Class 12 - Informatics Practices - JAVA Concepts (Worksheet) (#cbseNotes)

JAVA Concepts (Worksheet)


Q1: What will be the value of X1 after execution of the following code?
String X1 ="Graduate", X2 = "Post";
X1 = X2.contcat(X1);
Q2: What is the difference between the use of JTextField and JPasswordField in a form?
Q3: Name the method used to extract specified number of characters from a string?
Q4: Write the value of variable ‘c’ after execution of the following code:
int d;
int c;
d=7;
c=(5*++d)%3;

Q5: In which class the pow() and round() methods are found?
Q6: What is the difference between capacity() and length() methods of a String class?
Q7: What is the ouput of the following code:
System.out.println(Math.pow(4.0, 2.0));
System.out.println(Math.round(6.459));
Q8: The following code has some error(s). Rewrite the correct code underlining all the corrections made.
int marks, temperature;
marks = jTextField1.getText());
temperature = Integer.parseInt(jTextField2.getText());
if (marks<80) and (temperature>=40)
{
System.out.println(“Not Good”);
}
else;
{
System.out.println(“OK”);
}
Q9: How many times will the following WHILE loop execute?
int y = 7, sum = 0;
while (y<=15)
{
sum = sum +y;
y=y+2;
}
Q10: What will be the context of jTextArea1 and jTextField1 after the execution of the following statements?
(i)  jTextArea1.setText(“Just\tAnother\nDay”);

(ii) string Subject=”Informatics Practices”;
jTextField1.setText((Subject.length()+10)+” ”);

Comments