Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
class X
{
//Class X Members
}
class Y
{
//Class Y Members
}
class Z extends X, Y
{
//Class Z Members
}
//gabimi sepse class Z nuk mund te bej extend 2 klasa njeheresh
ushtrimi2:Cili eshte outputi
class A
{
int i = 10;
}
class B extends A
{
int i = 20;
}
public class MainClass
{
public static void main(String[] args)
{
A a = new B();
System.out.println(a.i);
}
}
//10
ushtrimi3:class A
{
{
System.out.println(1);
}
}
class B extends A
{
{
System.out.println(2);
}
}
class C extends B
{
{
System.out.println(3);
}
}
public class MainClass
{
public static void main(String[] args)
{
C c = new C();
}
} //1,2,3
ushtrim: Cili eshte output
class A
{
String s = "Class A";
}
class B extends A
{
String s = "Class B";
{
System.out.println(super.s);
}
}
class C extends B
{
String s = "Class C";
{
System.out.println(super.s);
}
}
public class MainClass
{
public static void main(String[] args)
{
C c = new C();
System.out.println(c.s);
}
}
//Class A
Class B
Class C
ushtrim:Cili do te jet output:
class A
{
static
{
System.out.println("THIRD");
}
}
class B extends A
{
static
{
System.out.println("SECOND");
}
}
class C extends B
{
static
{
System.out.println("FIRST");
}
}
public class MainClass
{
public static void main(String[] args)
{
C c = new C();
}
}
//third,second, first
ushtrim:Outputi me extend
class ClassOne
{
static int i, j = 191919;
{
--i;
}
{
j++;
}
}
public class ClassTwo extends ClassOne
{
static
{
i++;
}
static
{
--j;
}
public static void main(String[] args)
{
System.out.println(i);
System.out.println(j);
}
}
//1, 191918
ushtrim:Ca vlere mban i dhe j
class ClassOne
{
static int i = 111;
int j = 222;
{
i = i++ - ++j;
}
}
class ClassTwo extends ClassOne
{
{
j = i-- + --j;
}
}
i=-113, j=110
ushtrim:Cfare afishon
class ClassOne
{
char c = 'A';
{
c = 'B';
}
public ClassOne(char c)
{
this.c = c;
}
}
public class ClassTwo
{
public static void main(String[] args)
{
ClassOne one = new ClassOne('Z');
System.out.println(one.c);
}
}
//z
ushtrim:Gjej 5 gabimet
import java.awt.*;
public class Point {
int x; // Each Point object has
int y; // an int x and y inside.
public static void draw(Graphics g) { // draws this point
g.fillOval(p1.x, p1.y, 3, 3);
g.drawString("(" + p1.x + ", " + p1.y + ")", p1.x, p1.y);
}
public void translate(int dx, int dy) { // Shifts this point's x/y
int x = x + dx; // by the given amounts.
int y = y + dy;
}
public double distanceFromOrigin() { // Returns this point's
Point p = new Point(); // distance from (0, 0).
double dist = Math.sqrt(p.x * p.x + p.y * p.y);
return dist;
}
}
//
line 6: method header should not have the word static
line 12: should not re-declare field x (delete word int)
line 13: should not re-declare field y (delete word int)
line 17: should not declare Point p
line 18: should not use p. in front of the fields
import java.awt.*;
public class Point {
int x; // Each Point object has
int y; // an int x and y inside.
public void draw(Graphics g) { // draws this point
g.fillOval(x, y, 3, 3);
g.drawString("(" + x + ", " + y + ")", x, y);
}
public void translate(int dx, int dy) { // Shifts this point's x/y
x = x + dx; // by the given amounts.
y = y + dy;
}
public double distanceFromOrigin() { // Returns this point's
double dist = Math.sqrt(x * x + y * y); // distance from (0, 0).
return dist;
}
}
ushtrim:ushtrim me punonjesit
package employees;
/**
*
* @author Krishna
*/
import java.util.Scanner;
public class Employees {
String name;
int bonus;
long salary;
long totalsalary;
void accept()
{
Scanner s= new Scanner(System.in);
System.out.println("Enter Name of Employeesn");
name=s.nextLine();
System.out.println("Enter the Bonus of Employeen");
bonus=s.nextInt();
System.out.println("Enter the Salaryn");
salary=s.nextInt();
}
void calctotal()
{
totalsalary=salary+bonus;
}
void print()
{
System.out.println("Name of Employeen"+name);
System.out.println("Salary of Employeen"+salary);
System.out.println("Bonus of Employeen"+bonus);
System.out.println("Totalsalary of Employeen"+totalsalary);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Employees emp = new Employees();
emp.accept();
emp.calctotal();
emp.print();
// TODO code application logic here
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team