Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 False

Explanation / 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));

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote