- What is the difference between an object and a class? Give two examples.
- Explain the difference between
- int a = 3;
and
- Integer a = new Integer(3);
- For the following concepts/classes define/write at least one method:
- Animal
- Dog
- User
- File
- Database
- Q. For the following concepts/classes write at least one instance variable/attribute and an associated constructor you can define taking more than one input argument/parameter:
(a) MobilePhone
(b) User A.
(c) File
(d)Database
(e) Webpage
- What is the output of the following program:
class T { private int t = 20;
T(){
t = 40;
}
} class Main {
public static void main (String args []) {
T t1 = new T();
System.out.println(t1.t);
}
}
6. Is there any compiler error in the below Java program? Please explain your answer.
I dont accept only yes or no.
class Point {
int m_x, m_y; public Point (int x, int y) {m_x = x; m_y = y;} public static void main (String args []) { Point p = new Point();
}
}
7. Some aspects of each of the following can be modeled with a graph (network) structure. Describe, in each case what the nodes would represent and what the edges would represent. In general, nodes represent concepts/entities, and edges explain what the relationship is between the entities. For example, for navigation, nodes would represent locations (cities, towns, ) and edges between cities represent if a road exists between them (a weight can be added to denote the distance).
-
- Airline
- Social networks such as Facebook
- The Internet
- Movie industry
- Avengers (the movie/comic)
- Amazon.com recommendation system (where a system recommends to you what to buy)
- Describe and specify the order of growth of each of the following code sections, using big-O notation (explain your answer!):
(a) int count = 0; for (int i = 1; i < = N; i++) count ++;
(b) int count = 0; for (int i = 1; i <= N; i++)
for ( int j = 1; j <= N; j++) count ++;
(c) int count = 0; for (int i = 1; i <= N; i++) count ++;
for (int j = 1; j <= N; j++) count ++;
(d) int count = 0; for (int i = 1; i <= N/2; i++)
for ( int i = 1; i <= N/2; i++) count ++;
(e) public static String reverse ( String s) { int n = s.length(); char [] a = new char[n]; for (int i = 0; i < n; i++) a[i] = s.charAt(n-i-1); String reverse = new String (a); return reverse;
}
9. Describe the order of growth of each of the following functions using O notation:
(a) N2 + 3 N.
(b) 3 N + N
(c) N (N 1) + 2

![[Solved] CS20B Homework 1](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] CS20B Homework 3](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.