26 27 Analyze the following code Public dam Test private int ublic static void m
ID: 3808729 • Letter: 2
Question
26 27 Analyze the following code Public dam Test private int ublic static void main 80 args (Strin int x, System out. (t, printin r A The variable tis not initialized and therefore causes errors r B. The variable tis private and therefore cannot be accessed in the main method. c C,tis non-static and it cannot be referenced in a static context n the main method r D. The variable xis not initialized and therefore causes errors CE. The program compiles and runs fine. Every instance data field fin the class can be referenced using this fin a static method the same class, C True FalseExplanation / Answer
Question 26:
Answer is : t is non-static variable cannot be referenced from a static context in the main method
you can only call by:
public class Test
{
private int t;
public static void main(String []args)
{
Test test = new Test();
int x;
System.out.println(test.t);
}
}
Question 27:
Answer is : False
public class Test
{
private int t;
public static void main(String []args)
{
Test test = new Test();
int x;
System.out.println(test.t);
}
}
as you can see i have object called test to access t variable
Question 30:
Answer is : strBuf.delete(1,4)
delete(starting postion , end position);
Question 31:
You can convert string to int by all the options
Integer.parseInt(s);
(new Integer(s)).intValue();
Integer.valueOf(s).intValue();
Integer.valueOf(s);
(int)(Double.parseDouble(s));
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.