Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. What is the output of the following code? public class B { int x=5; public static void main(String[] args) { B b1 = new

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
2. What is the output of the following code? public class B { int x=5; public static void main(String[] args) { B b1 = new BO; Bb2 = new BO: b1.x= 10: System.out.println(b2x): 1 1. What the difference between the Primitive Variable and the Reference variable? Give an example for each of them 4. define the error in the following code: class A{ private int x=3; public int y=5; } class B{ void mo { A a1= new AO a 1.x=4 al.y=B: 5. What is the output of the following code? public class Abc { static int z=5; public static void main(String[] args) { Abc obj1 = new Abco: Abc obj2 = new Abc0; obj1 .z= 10; System.out.println(obj2.z); } 6. What is the data field encapsulation? 7. define the error in the following code: public class hello { int x= 10; static void methodol X= 20 8. Using java: 1:-define a class (myclass). 2:- define two constructors for the class: The first constructor with no-argument and the second constructer has one string argument. 3:-declare and create two objects from the class myclass ( using the two constructors). (3 Points) 3. A class has a default constructor only if the class does not define any constructor. (1 Point) True False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions