Está en la página 1de 13

Declarations and Access Control Modifiers fall into two categories: Access modifiers:public,protected,private Nonaccess modifiers (includingstrictfp,final, andabstract)

t) A class can be declared with only public or default access. (Additionally Strictfp, abstract, final) he other two access control levels protected,private don!t ma"e sense for a class #our access controls (which means all three modifiers $ default) wor" for most method and variable declarations Class Access (Visibility) Default Access: A class with default access can be seen only by classes within the same package. Note: If class A and class B are in different packages, and class A has a default access, class B won t be able to create an instance of class A, or e!en declare a !ariable or a return type of class A" #o these two things to $ake it work, place class A, class B in the sa$e package (or) declare class A with public access $odifier" Exam Watch : %hen you see a &uestion with co$ple' logic, be sure to look at the access $odifiers first" (hat way, if you spot an access !iolation (for e'a$ple, a class n package A trying to access a default class in package B), you ll know the code won t co$pile so you don t ha!e to bother working through the logic" It s not as if, you know, you don t ha!e anything better to do with your ti$e while taking the e'a$" )ust choose the *Co$pilation fails+ answer and ,oo$ on to the ne't &uestion" Public Access: A class declaration with the public keyword gives all classes from all packages access to the public class. visible to all classes in all packages. -ther (Nonaccess) Class .odifiers: %an modify a class declaration using the "eyword final,abstract, or strictfp. hese modifiers are in addition to whatever access control is on the class. &ou can!t always mi' non abstract modifiers. never! ever! ever mark a class as both final and abstract. "#ell me why$% strictfp is a "eyword and can be used to modify a class or a method, but never a variable. Mar"ing a class as strictfp means that any method code in the class will conform to the ()))*+, standard rules for floating points. Final %lasses -hen used in a class declaration, the final "eyword means the class can!t be sub classed. No other class can ever e'tend (inherit from) a final class. #inal can be used to modify a class or a method or a variable. Abstract %lasses: An abstract class can never be instantiated. (t is to be e'tended (subclassed). Abstract can be used to modify a class, a method but never a variable. Exam Watch: /ook for &uestions with a $ethod declaration that ends with a se$icolon, rather than curly braces" If the $ethod is in a class0as opposed to an interface0then both the $ethod and the class $ust be $arked abstract" 1ou $ight get a &uestion that asks how you could fi' a code sa$ple that includes a

$ethod ending in a se$icolon, but without an abstract $odifier on the class or $ethod" In that case, you could either $ark the $ethod and class abstract, or re$o!e the abstract $odifier fro$ the $ethod" -h, and if you change a $ethod fro$ abstract to non abstract, don t forget to change the se$icolon at the end of the $ethod declaration into a curly brace pair2 &emember: 3!en a single $ethod is abstract, the whole class $ust be declared abstract" Can put non abstract $ethods in the abstract class" Exam Watch: 1ou can t $ark a class as both abstract and final" (hey ha!e nearly opposite $eanings" An abstract class $ust be subclassed, whereas a final class $ust not be subclassed" If you see this co$bination of abstract and final $odifiers, used for a class or $ethod declaration, the code will not co$pile" .ethod and Variable #eclarations and .odifiers Methods and instance (nonlocal) variables are collectively "nown as members. %an modify a member with both access and non.access modifiers. Member Access: public, protected, private, default. Exam Watch: It s crucial that you know access control inside and out for the e'a$" (here will be &uite a few &uestions with access control playing a role" 4o$e &uestions test se!eral concepts of access control at the sa$e ti$e, so not knowing one s$all part of access control could blow an entire &uestion" 'uestion: %hat does it $ean for code in one class to ha!e access to a $e$ber of another class5 (he $e$ber in class A should be !isible to class B &ou need to understand two different access issues: /. -hether method code in one class can access a member of another class. . (0sing reference). 1.-hether a subclass can inherit a member of its superclass (use e'tend and access it by inheritance iff the member should be visible) (f a subclass inherits a member, the subclass has the member. Exam Watch: 1ou need to know the effect of different co$binations of class and $e$ber access (such as a default class with a public !ariable)" (o figure this out, first look at the access le!el of the class" If the class itself will not be !isible to another class, then none of the $e$bers will be either, e!en if the $e$ber is declared public" -nce you !e confir$ed that the class is !isible, then it $akes sense to look at access le!els on indi!idual $e$bers" Public: -hen a method or variable member is declared public, it means all other class regardless of the pac"age can access the member.(assuming the class itself is visible). (f a member of its superclass is declared public, the subclass inherits that member regardless of whether both classes are in the same pac"age. (n the subclass, you can invo"e the super class method without reference. (-ithout the dot operator). 0sing reference also wont hurt. he reference this always refers to the currently e'ecuting ob2ect. this reference is implicit. Private: Members mar"ed private can!t be accessed by code in any class other than the class in which the private member is declared. A private member is invisible to any code outside the member(s own class. Question: -hat about a subclass that tries to inherit a private member of its superclass3 A subclass can!t inherit it.

A subclass can!t see or use or even thin" about private members of its super class. &ou can however have a matching method in the subclass with the same method name in the super class. (t is simply a method that happens to have the same method name as the private method in the super class. 4verriding rules does not apply. On the ob: (n practice it!s nearly always best to "eep all variables private or protected. (f variables needs to be changed programmers should use public accessor methods. Question: %an a private method be overridden by a subclass3 No. Since the subclass cannot inherit the private method, it therefore cannot override the method. (4verriding depends on inheritance). Default !embers: A default member can be accessed only if the class accessing the member belongs to the same pac"age. Protected !embers: A protected member can be accessed (through inheritance) by a subclass even if the subclass is in the different pac"age. Note: &ou cannot access protected member using ob2ect reference. he subclass cannot use the dot operator on the superclass reference to access the protected member. Question 5ut what does it mean for a subclass.outside the pac"age to have access (visibility to a superclass (parent) member3 (t means the subclass inherits the member. #he subclass can only see the protected member through inheritance. #or a subclass outside the pac"age, the protected member can be accessed only through inheritance. Question: -hat does a protected member loo" li"e to other classes trying to use the subclass.outside.the.pac"age to get the subclass! inherited protected superclass member3 Say for e': class A is in 6ac"age A, class 5 is in 6ac"age 5. class 5 is accessing the protected member ' in class A. -hat happens if some class say class % in the same pac"age 5 has a reference to class 5 wants to access the member variable ' (protected member in class A). 7ow does that protected member behave once the subclass has inherited it3 8oes it maintain its protected status, such that classes in the %hild!s pac"age can see it3 )o. -nce the subclass6outside6the package inherits the protected $e$ber, that $e$ber (as inherited by the subclass) becomes private to any code outside the subclass" #he bottom line: when a subclass6outside6the6package inherits a protected $e$ber, the $e$ber is essentially pri!ate inside the subclass, such that only the subclass own code can access it" Question: -hat about default access for two classes in the same pac"age3 (t wor"s fine. 9emember that default members are visible only to the subclasses are in the same pac"age as the superclass. /ocal Variables and Access .odifiers Question: %an access modifiers be applied to local variables3 "o# Exam Watch: (here is ne!er a case where an access $odifier can be applied to a local !ariable, so watch out code like the following"
class #oo : void doStuff() :

private int ' ; *< this.doMore(')< = =

&ou can be certain that any local variable declared with modifier cannot compile. (n fact there is only one modifier can ever be applied to a local variables.final# *isibility Public Protected Default Private 7ro$ the sa$e class 1es 1es 1es 1es 7ro$ any class in the 1es 1es 1es No sa$e package 7ro$ any non6 1es No No No subclass class outside the package" 7ro$ a subclass in the 1es 1es 1es No sa$e package 7ro$ a subclass 1es 1es No No outside the sa$e package" NonAccess .e$ber .odifiers #inal, abstract, transient, synchroni>ed, strictfp, native. Final !ethods: he final "eyword prevents a method from being overridden in a subclass. Final Ar$uments: Method arguments are essentially the same as the local variables. %an declare the method arguments as final. Abstract !ethods: An abstract method is a method that has been declared but has to be implemented. his method contains no functional code. An abstract method does not even have the curly braces for the functional implementation, instead it closes with the semicolon. &ou can have abstract class with no abstract methods. Any class that e'tends abstract class has to implement all abstract methods of the superclass. 0nless the subclass is also abstract. 8ule is: (he first concrete ($eans Non abstract) subclass of an abstract class $ust i$ple$ent all abstract $ethods of the superclass" (f the subclass is abstract it is not re?uired to implement the abstract methods of the superclass, but it is allowed to implement any or all of the superclass abstract methods. Exam Watch: /ook for concrete classes that don t pro!ide $ethod i$ple$entations for abstract $ethods of the superclass" 7or e'a$ple, the following code won t co$pile: public abstract class A : abstract void foo()< = class 5 e'tends A : void foo(int () : = = Class B won t co$pile because it doesn t i$ple$ent the inherited abstract $ethod foo()" Although the foo(int ()$ethod in class B $ight appear to be an i$ple$entation of the superclass abstract $ethod, it is si$ply

an o!erloaded $ethod (a $ethod using the sa$e identifier, but different argu$ents), so it doesn t fulfill the re&uire$ents for i$ple$enting the superclass abstract $ethod" "ote: A method can never ever be mar"ed as both abstract and final or both abstract and private. hin"@@ Abstract methods has to be implemented, whereas final and private methods cannot be overridden by the subclass. Abstract methods cannot be mar"ed as s%nchroni&ed, strictfp or native, static# '%nchroni&ed !ethods: he synchroni>ed "eyword indicates that the method can be accessed by only one thread at a time. Synchroni>ed "eyword can be applied only to methods. Synchroni>ed modifier can be paired with any of the four access control levels. (private, public, default, protected). Synchroni>ed can be paired with final but not with abstract "ative !ethods: he native "eyword indicates that a method is implemented in a platform dependent language such as %. Native can never be combined with abstract. Native can be applied only to methods, not to classes , variables. 'trictfp !ethods: Strictfp forces floating point operations to adhere ())*+, standard. Strictfp can modify a class or nonabstract method declaration and that a Aariable can never be declared strictfp. Aariable 8eclarations (nstance )ariables: (nstance variables are defined inside the class but outside the method. 4nlu initiali>ed when the class is instantiated. (nstance variables can use any of the four access levels. %an be mar"ed #inal, transient, abstract, strictfp, native, synchroni>ed. *ocal variables: Bocal variables are declared within the method. Means variables is not 2ust initiali>ed within the method but also declared within the method. (t starts its life inside the method, it!s also destroyed when the method has completed. *ocal variables are al+a%s on the stac,, not the heap# -et clarified# P$:./ Bocal variable declarations can!t use most of the modifiers such as public, transient, volatile, abstract, static. Bocal variables can be mar"ed final# 5efore using the local variable it should be initiali>ed. Bocal variables don!t get default values. Bocal variables can!t be referenced outside the method in which it is declared. (t is possible to declare the local variable with the same name as an instance variable. hat!s "nown as shado+in$. he following (but wrong) code is trying to set an instance variable!s value using a parameter: class #oo : int si>e ; 1*< public void setSi>e(int si>e) : si>e ; si>e< CC 333 which si>e e?uals which si>e333 =

= 0se the "eyword this# he this "eyword always always refers to the ob2ect currently running. Final )ariables: (mpossible to reinitiali>e the variable once it has been initiali>ed. #or primitives, once the variable is assigned a value, the value can!t be altered. Question: -hat does it mean to have a final ob9ect reference5 A reference variable mar"ed final can!t ever be reassigned to refer to a different ob2ect. he data within the ob2ect, however can be modified but the reference variable cannot be changed. 1ou can use final references to $odify the ob9ect it refers to, but you can t $odify the reference !ariable to $ake it refer to a different ob9ect" 9emember there are no final ob ects, onl% final references# Exam Watch: Boo" for code that tries to reassign a final variable, but don!t e'pect to be obvious. #or e'ample, a variable declared in an interface is always implicitly final, whether you declare it that way or not. +o you might see code similar to the following:
interface #oo : (nteger ' ; new (nteger(+)< CC ' is implicitly final = class #oo(mpl implements #oo : void doStuff() : ' ; new (nteger(+)< CC 5ig rouble@ %an!t assign new ob2ect to ' = =

he reference variable ' is final. (t is an interface variable, they are always implicitly public static final" #inal can!t be reassigned, that in the case of interface variables, they are final even if they don!t say it out loud. #he exam expects you to spot any attempt to violate this rule. 0ransient )ariables: (f you mar" an instance variable as transient, (9emember: only you can declare final to the local variable) you!re telling the DAM to s"ip this variable when you attempt to seriali>e the ob2ect declaring it. 'eriali&ation lets u save an ob2ect by writing its state to a special (4 writing stream. For exam %ou need ,no+: #ransient can be applied only to instance !ariables" )olatile )ariables: he volatile tells the DAM that a thread accessing the variable must always reconcile its own private copy of the variable with the master copy in the memory. For exam %ou need ,no+: *olatile can be applied only to instance !ariables" 'tatic variables and methods: %an use a static method or a variable without having any instances of that class at all. Aariables and methods mar"ed static belong to the class. he rule is, a static method of a class can!t access a nonstatic (instance) memberEmethod or variableof its own class. Exam Watch: ,ne of the mistakes most often made by new -ava
programmers is attempting to access an instance variable "which means nonstatic variable% from the static main()method "which doesn(t know anything about any instances! so it can(t access the variable%. #he following code is an example of illegal access of a nonstatic variable from a static method:

class #oo : int ' ; F< public static void main (String GH args) : System.out.println(I' is I $ ')< = = .nderstand that this code will never compile! because you can(t access a nonstatic "instance% variable from a static method. -ust think of the compilersaying! /0ey! 1 have no idea which 2oo ob3ect(s ' variable you(re trying to print45 &emember! it(s the class running the main()method! not an instance of the class. ,f course! the tricky part for the exam is that the 6uestion won(t look as obvious as the preceding code. #he problem you(re being tested for7 accessing a nonstatic variable from a static method7will be buried in code that might appear to be testing something else. 2or example! the code above would be more likely to appear as class #oo : int ' ; F< float y ; ,.Ff< public static void main (String GH args) : for (int > ; '< > J $$'< >.., y ; y $ >) : CC complicated looping and branching code = = +o while you(re off trying to follow the logic! the real issue is that ' and y can(t be used within main()! because ' and y are instance! not static! variables4 #he same applies for accessing nonstatic methods from a static method. #he rule is! a static method of a class can(t access a nonstatic "instance% member7 method or variable7of its own class.

Accessin$ 'tatic !ethods and )ariables: Access a static method or static variable is to use the dot operator on the class na$e, as opposed to on a reference to an instance variable. Also 2ava allows you to access the static members using the ob2ect reference variable. Static methods can!t be overridden. hings you can mar" as 'tatic: Methods, Aariables, op.level nested classes. hings you can!t mar" as 'tatic: %onstructors (constructor is used only to create instances), %lasses, (nterfaces, (nner %lasses, (nner class methods and variables, Bocal variables. 4tatic $ethod cannot access an instance (non6static) !ariable" (re$e$ber about $ain $ethod) 4tatic $ethod cannot access a non6static $ethods" 4tatic $ethod can access a static $ethod and !ariable" Static members are per.class as opposed to per.instance. 'ource files, Pac,a$e, Declarations and (mport 'tatements# here can be only one pac"age statement per source code file. %an have only one pubic class per source code file. ,n the -ob: :utting $ultiple classes in the sa$e source code file $akes it $uch harder to locate the source for a particular class and $akes the source code less reusable"

Exam Watch: #he exam uses a line numbering scheme that indicates whether the code in the 6uestion is a snippet "a partial code sample taken from a larger file%! or complete file. 1f the line numbers start at 8! you(re looking at a complete file. 1f the numbers start at some arbitrary "but always greater than 8% number! you(re looking at only a fragment of code rather than the complete source code file. 2or example! the following indicates a complete file: /. pac"age fluffy< 1. class 5unny : F. public void hop() : = ,. = whereas the following indicates a snippet: K. public void hop() : /L. System.out.println(IhoppingM)< //. = Exam Watch: 1ou $ight see &uestions that appear to be asking about classes and packages in the core )a!a A:I that you ha!en t studied, because you didn t think they were part of the e'a$ ob9ecti!es" 7or e'a$ple, if you see a &uestion like class #oo e'tends 2ava.rmi.0nicast9emote4b2ect : CCC more code = don t panic2 1ou re not actually being tested on your 8.I knowledge, but rather a language and;or synta' issue" If you see code that references a class you re not fa$iliar with, you can assu$e you re being tested on the way in which the code is structured, as opposed to what the class actually does. In the preceding code e'a$ple, the &uestion $ight really be about whether you need an i$port state$ent if you use the fully &ualified na$e in your code (the answer is no, by the way)" Exam Watch: /ook for synta' errors on i$port state$ents" Can you spot
what s wrong with the following code5 import 2ava.util.Arraylist.N< CC -ildcard import import 2ava.util< CC )'plicit class import (he first i$port looks like it should be a !alid wildcard i$port, but Array/ist is a class, not a package, so it $akes no sense (not to $ention $aking the co$piler cranky) to use the wildcard i$port on a single class" :ay attention to the synta' detail of the i$port state$ent, by looking at how the state$ent ends" If it ends with .N<(dot, asterisk, se$icolon), then it $ust be a wildcard state$ent< therefore, the thing i$$ediately preceding the .N<$ust be a package na$e, not a class na$e" Con!ersely, the second i$port looks like an e'plicit class i$port, but util is a package, not a class, so you can t end that state$ent with a se$icolon"

Question: -hat happens if you have two classes with the same name in two different pac"ages, and you want to use both in the same source code3 &ou should use fully ?ualified name. static public void main (String whatever GH) : = O his method is perfectly legal. he most important point for the e'am is to "now that not having the Iable.to. runM main() method is a runtime, rather than compiler error. A class with a legal, nonstatic main()$ethod, for e'a$ple, will co$pile 9ust fine, and other code is free to call that $ethod" But when it co$es ti$e to use that class to in!oke the )V., that nonstatic main()$ethod 9ust won t cut it, and you ll get the runti$e error"

1nterface 1mplementation: Exam Watch: 1ou $ust know how to i$ple$ent the 9ava.lang.9unnableinterface,without being shown the code in the &uestion" In other words, you $ight be asked to choose fro$ a list of si' classes which one pro!ides a correct i$ple$entation of 9unnable" Be sure you $e$ori,e the signature of the one and only one 9unnableinterface $ethod: public void run() : = 7or any other interface6related &uestion not dealing with 9unnable, if the specification of the interface $atters, the interface code will appear in the &uestion" A &uestion, for e'a$ple, $ight show you a co$plete interface and a co$plete class, and ask you to choose whether or not the class correctly i$ple$ents the interface" But if the &uestion is about 9unnable, you won t be shown the interface" 1ou re e'pected to ha!e 9unnable$e$ori,ed2 (nterface: -hat a class can do without saying anything about how the class will do it. hin" of an interface as a /LL.percent abstract class. Bi"e an abstract class interface defines abstract methods. 5ut while an abstract class can define both abstract and non.abstract methods. (nterface can have only abstract methods. (nterface has very little fle'ibility in how the methods and variables defined in the interface are declared. he rules are strict, but simple. All interface methods must be implemented and must be mar"ed public. -hat you declare in the interface : interface bounceable= void bounce()< void setbouncefactor(int bf)< > -hat the compiler loo"s: interface bounceable= public abstract void bounce()< public abstract void setbouncefactor(int bf)< > All interface methods are implicitly public and abstract. (nterface methods must not be static. &ou do not need to actually type the public and abstract modifiers in the method declaration, but the method is still always public and abstract. All variables defined in the method must be public static final. (n other words, interfaces can declare only constants, not instance variables. 5ecause interface methods are abstract, they cannot be mar"ed as final, native, synchroni>ed, strictfp. An interface can e'tend one or more interfaces. An interface cannot e'tend anything but another interface. An interface cannot implement another interface or class. (nterface must be declared with the "eyword interface. public interface 9ollable := , public abstract interface 9ollable : = O 5oth are legal. Since interfaces are implicitly abstract. Exam Watch: /ook for interface $ethods declared with any co$bination of public,abstract, or no $odifiers" 7or e'a$ple, the following fi!e $ethod declarations, if declared within an interface, are legal and identical2

void bounce()< public void bounce()< abstract void bounce()< public abstract void bounce()< abstract public void bounce()< #he following interface method declarations won(t compile: final void bounce()< CC final and abstract can never be used static void bounce()< CC interfaces define instance methods private void bounce()< CC interface methods are always public protected void bounce()< CC (same as above) synchroni>ed void bounce()< CC can!t mi' abstract and synchroni>ed native void bounce()< CC can!t mi' abstract and native strictfp void bounce()< CC can!t mi' abstract and strictfp 5y placing the constants in the interface, any class that i$ple$ents the interface has direct access to the constants, 9ust as if the class had inherited the$" Interface constants $ust always be public! static! final. Any variable declared in the interface must be implicitly is O a public constant. Exam Watch: 9ook for interface definitions that define constants! but without explicitly using the re6uired modifiers. 2or example! the following are all identical: public int ' ; /< CC Boo"s non.static and non.final, but isn!t@ int ' ; /< CC Boo"s default, non.final, and non.static, but isn!t@ static int ' ; /< CC 8oesn!t show final or public final int ' ; /< CC 8oesn!t show static or public public static int ' ; /< CC 8oesn!t show final public final int ' ; /< CC 8oesn!t show static static final int ' ; / CC 8oesn!t show public public static final int ' ; /< CC )'actly what you get implicitly Any combination of the re6uired "but implicit% modifiers is legal! as is using no modifiers at all4 ,n the exam! you can expect to see 6uestions you won(t be able to answer correctly unless you know! for example! that an interface variable is final and can never be given a value by the implementing "or any other% class. -hile implementing the interface O 6rovide concrete implementations for all methods from the declared interface. O #ollow all the rules for legal overrides O 8eclare no chec"ed e'ceptions on implementation methods other than those declared by the interface methods or subclass of those declared by the interface method. O Maintain the signature of the interface method, and maintains the same return type. 5ut does not have to declare the e'ceptions declared in the interface method declaration. An implementation class can itself be abstract. -hen the implementation class itself is abstract, it simply passes the buc" to its first concrete subclass. Exam Watch: /ook for $ethods that claim to i$ple$ent an interface but don t pro!ide the correct $ethod i$ple$entations" ?nless the i$ple$enting class is abstract, the i$ple$enting class $ust pro!ide i$ple$entations for all $ethods defined in the interface" A class can e'tend $ore than one interface &ou can e'tend only one class but implement many interface. An interface can e'tend another interface, but cannot i$ple$ent another interface"

public interface 5ounceable e'tends Moveable : = . 6erfectly legal. he first concrete implementation class of 5ounceable interface, should implement all the methods of 5ounceable 6lus all the methods in Moveable interface. An interface can extend more than one interface# 0hin,111 Question: A class is not allowed to e'tend multiple classes. (f it does then it would be multiple inheritance 5ut why in (nterface interface 5ounceable e'tends Moveable, spherical : void bounce()< void set5ounce#actor(int bf)< = class 5all e'tends 5ounceable O this class has to implement all the methods in 5ounceable, Moveable, Spherical. (f not then class 5all is mar"ed abstract. Exam Watch: /ook for illegal use of e'tends and i$ple$ents" (he following shows e'a$ples of legal and illegal class and interface declarations" /. class #oo : = 1. class 5ar implements #oo : = F. interface 5a> : = ,. interface #i : = +. interface #ee implements 5a> : = P. interface Qee implements #oo : = *. interface Qoo e'tends #oo : = R. interface 5oo e'tends #i : = K. class oon e'tends #oo, 5utton : = /L. class Qoom implements #i, #ee : = //. interface Aroom e'tends #i, #ee : = -k" No" Class cannot i$ple$ent another class" -k" -k" No" Interface cannot i$ple$ent another interface" It can only e'tend another interfaces" E" No" Interface cannot i$ple$ent another class" F" No" Interface cannot e'tend class" It will e'tend only interfaces" G" -k" H" No" Class cannot e'tend two classes" @I" -k" Class can i$ple$ent $ultiple interface" @@" -k" interface can e'tend $ultiple interfaces" :urn these in! and watch for abuses in the 6uestions you get on the exam. &egardless of what the 6uestion appears to be testing! the real problem might be the class or interface declaration. :efore you get caught up in! say! tracing a complex threading flow! check to see if the code will even compile. "-ust that tip alone may be worth your putting us in your will4% ";ou(ll be impressed by the effort the exam developers put into distracting you from the real problem.% "0ow did people manage to write anything before parentheses were "was$% invented$% @" A" B" C" D"

Assertions: Bet you to test your assumptions during development, without the e'pense (in both your time and program overhead) of writing e'ception handlers for e'ceptions that you assu$e will ne!er happen once the program is out of development and fully deployed.

También podría gustarte